import numpy as np
%matplotlib notebook
import matplotlib.pyplot as plt
plt.style.use ('ggplot')
from sklearn.manifold import TSNE
from sklearn.decomposition import PCA
from gensim.test.utils import datapath, get_tmpfile
from gensim.models import KeyedVectors
from gensim.scripts.glove2word2vec import glove2word2vec
Hello everyone, I hope you all are doing well. I am new in DL and NLP. As I am learning I came across this error. Can anyone help me solve this issue? thank you all.
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-13-8db7eebe6f3e> in <module>
7 from sklearn.decomposition import PCA
8
----> 9 from gensim.test.utils import datapath, get_tmpfile
10 from gensim.models import KeyedVectors
11 from gensim.scripts.glove2word2vec import glove2word2vec
ModuleNotFoundError: No module named 'gensim'
Related
I learned a lot of solutions from this website, but still cannot solve the problem. My code is as follows for your review:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import missingno as msno
import altair as alt
from statsmodels.graphics.mosaicplot import mosaic
from scipy.stats import chi2_contingency
import plotly.express as px
from pandas.plotting import parallel_coordinates
from wordcloud import WordCloud
import networkx as nx
from networkx.drawing.nx_agraph import graphviz_layout
from scipy.spatial import distance
!pip install sklearn
from sklearn.experimental import enable_iterative_imputer
from sklearn.impute import IterativeImputer
from sklearn.impute import KNNImputer
from missingpy import MissForest
import sklearn.neighbors._base
sys.modules['sklearn.neighbors.base'] = sklearn.neighbors._base
import warnings
warnings.filterwarnings("ignore")
And still shows the error: ModuleNotFoundError: No module named 'sklearn.neighbors.base' I've tried to do the follows:
pip install -U imbalanced-learn ;
pip install -U scikit-learn
ans there was still of no use
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_11280/2643854484.py in <module>
26 from sklearn.impute import IterativeImputer
27 from sklearn.impute import KNNImputer
---> 28 from missingpy import MissForest
29 import sklearn.neighbors._base
30 sys.modules['sklearn.neighbors.base'] = sklearn.neighbors._base
C:\ProgramData\Anaconda3\lib\site-packages\missingpy\__init__.py in <module>
----> 1 from .knnimpute import KNNImputer
2 from .missforest import MissForest
3
4 __all__ = ['KNNImputer', 'MissForest']
C:\ProgramData\Anaconda3\lib\site-packages\missingpy\knnimpute.py in <module>
11 from sklearn.utils.validation import check_is_fitted
12 from sklearn.utils.validation import FLOAT_DTYPES
---> 13 from sklearn.neighbors.base import _check_weights
14 from sklearn.neighbors.base import _get_weights
15
ModuleNotFoundError: No module named 'sklearn.neighbors.base'
Finally, I solved the problem!!
I should write this before import missingpy, not behind it.
import sklearn.neighbors._base
import sys
sys.modules['sklearn.neighbors.base'] = sklearn.neighbors._base
from missingpy import MissForest
done.
import torch
import torch.nn as nn
import torchvision.datasets as dsets
from skimage import transform
import torchvision.transforms as transforms
from torch.autograd import Variable
import pandas as pd
import numpy as np
from torch.utils.data import Dataset, DataLoader
from vis_utils import *
import random
import math
I am getting the error below:
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_10608/4005546520.py in <module>
8 import numpy as np
9 from torch.utils.data import Dataset, DataLoader
---> 10 from vis_utils import *
11 import random
12 import math
ModuleNotFoundError: No module named 'vis_utils'
You probably have to install the vis_utils module https://www.npmjs.com/package/vis-utils
I'm currently having trouble importing some simple packages.
I'm working on pycharm professional in a virtual environment.
just trying to load;
import pandas as pd
import numpy as np
from sklearn.ensemble import IsolationForest
from sklearn.ensemble._iforest import _average_path_length
import shap
importError Traceback (most recent call last)
<ipython-input-1-5b7f1bf909af> in <module>
----> 1 import pandas as pd
2 import numpy as np
3 from sklearn.ensemble import IsolationForest
4 from sklearn.ensemble._iforest import _average_path_length
5 import shap
~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pandas\__init__.py in <module>
14
15 if missing_dependencies:
---> 16 raise ImportError(
17 "Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
18 )
ImportError: Unable to import required dependencies:
numpy: cannot import name 'asanyarray' from 'numpy.core.multiarray' (C:\Users\James\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\numpy\core\multiarray.py
I've never come across this error before so don't know how to fix.
I am trying to do a Topic modeling project, but when I use
from sklearn.feature_extraction import TfidfVectorizer
I will receive this error, my sckit-learn version installed is 0.24.1. I will be grateful if anyone could help me.
ImportError Traceback (most recent call last)
<ipython-input-2-5ae89ed22b7e> in <module>
----> 1 from sklearn.feature_extraction import TfidfVectorizer
ImportError: cannot import name 'TfidfVectorizer' from 'sklearn.feature_extraction' (C:\Users\mozha\Anaconda3\envs\spyder-env\lib\site-packages\sklearn\feature_extraction\__init__.py)
You have to import vectorizers like TfidfVectorizer from sklearn.feature_extraction.text and not sklearn.feature_extraction.
import re
from collections import Counter
from itertools import chain
import numpy as np
import pandas as pd
from nltk.corpus import stopwords
from sklearn.metrics import mean_absolute_error as mse
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression,huber
from sklearn.svm import SVR
from sklearn.ensemble import RandomForestRegressor
from sklearn.neighbors import KNeighborsRegressor
from sklearn.ensemble import AdaBoostRegressor, GradientBoostingRegressor
from util import shortWord_Dictionary, load_glove
These are the libraries i am trying to import but i am getting this error.
i have tried few other solutions such as importing subclasses like add and concentrate but still it is not working, Help me out here
Error is:
ImportError Traceback (most recent call last)
<ipython-input-9-acc83d608c96> in <module>
15 import tensorflow.contrib.keras as keras
16
---> 17 from util import shortWord_Dictionary, load_glove
~\Downloads\thesis-final\thesis-final\Microsoft\util.py in <module>
6 from keras import initializers
7 from keras.callbacks import ModelCheckpoint, EarlyStopping, ReduceLROnPlateau
----> 8 from keras.layers import Dropout, Embedding, Convolution1D, Dense, Merge
9 from keras.layers.recurrent import LSTM
10 from keras.models import Sequential
ImportError: cannot import name 'Merge' from 'keras.layers' (C:\Users\DARSHIT\Anaconda3\Anaconda\lib\site-packages\keras\layers\__init__.py)
keras doesn't have Merge layers, see the docs. Merge is just the name that they gave to a subset of the layers, namely Add, Multiply, or Average.