kaggleword2vec utility not found - python

I'm trying to follow along with some tutorials to complete some projects/competitions but I can't seem to find "kaggleword2vec"; any suggestions?
import os
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.ensemble import RandomForestClassifier
from KaggleWord2VecUtility import KaggleWord2VecUtility
import pandas as pd
import numpy as np
Traceback (most recent call last):
File "/Users/jordanXXX/Documents/NLP/sentimentanalysis9", line 4, in <module>
from KaggleWord2VecUtility import KaggleWord2VecUtility
ImportError: No module named KaggleWord2VecUtility
Where can I find the KaggleWord2VecUtility? I have Word2Vec and a bunch of other toolkits I've been using but this one in particular isn't recognized. I'd like to continue following the tutorials but can't seem to without this module.
Thanks

You can get everything you need here https://github.com/wendykan/DeepLearningMovies

Related

Python master import file

I have several scripts in a project folder, most of which use the same handful of standard libraries and modules. Instead of having to reiterate in every single script
import pandas as pd
import numpy as np
import datetime
import re
etc
etc
is it possible for me to place all import statements in a masterImports.py file and simply import masterImports at the top of each script ?
Yes you can.
So the basic idea is to import all the libraries in one file. Then import that file.
An example:
masterImports.py
import pandas as pd
import numpy as np
import datetime
import re
etc
etc
otherFile.py
import masterImports as mi
print(mi.datetime.datetime(2021,7,20))
Or you could use wildcard imports -
from masterImports import * # OR from masterImports import important_package
print(datetime.datetime(2021,7,20))
Do not use wildcard asterix imports because there can be name clashes
Try this, and you will see that there is no error
It's possible, although not really the done thing
To use it, you'd need to do, at the top of each script:
from master_imports import *

CSV file does not exist

I am trying to pull the file "house_date.csv" and I ma being unssucesful becasue python is stating that the file cannot be found. is there a better way for me to figure out how I can load the file ? I am also not sure in what directory is located.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
import math
pd.read_csv('house_data.csv')
This is the error message I am getting .
When you write pd.read_csv('house_data.csv'), the csv file directory and the python working directory is supposed to be the same.
Try to replace house_data.csv with the complete path (for example C:/house_data.csv, if the file is in "C").

NLTK corpora : IndexError: list index out of range

Here when I run this particular code
import os
import nltk
import nltk.corpus
print(os.listdir(nltk.data.find("corpora"))) `
I get
IndexError Traceback (most recent call
last)
IndexError: list index out of range
I run this code without error.
If there is problem with data then you should get this error also with two lines:
import nltk
print(nltk.data.find("corpora"))
As I remember nltk at start needs to download data from server - and this can be the problem.
import nltk
nltk.download()
See doc: Installing NLTK Data

Is it possible to reuse import code in Python?

There are several imports that are common between some files in my project. I would like to reuse this code, concentrating it in a unique file and have just one import in the other files. Is it possible?
Or is there another way not to replicate the desired import list in multiple files?
Yes its possible. You can create a Python file with imports and then import that Python file in your code.
For Eg:
ImportFile.py
import pandas as pd
import numpy as np
import os
MainCode.py:
from ImportFile import *
#Here you can use pd,np,os and complete your code
OR
from ImportFile import pd,np
#And then use pd and np

Python cannot import CSV using DataFrame

I am using Pandas to import some csv file into Python.
my code is:
import pandas as pd
data_df = pd.read_csv('highfrequency2.csv')
print data_df.head()
but there is always an error message:
**Traceback (most recent call last):
File "G:\Python\sdfasdfasdfasdfasdf.py", line 7, in <module>
import pandas as pd
File "G:\Python\pandas.py", line 9, in <module>
from pandas import DataFrame
ImportError: cannot import name DataFrame**
Can some one figure out why ? Many thanks !!!
It look like you've called one of your own programs pandas:
G:\Python\pandas.py
So this is the one Python is trying to import, and the one which doesn't have a DataFrame object.
Rename your program, delete any cached objects (pandas.pyc or pandas.pyo), and restart your Python interpreter.

Categories