Import error: No module name sklearn.external.six - python

I am currently using anaconda 4.8.3 and want to display a figure of decision tree and i have install graphviz and pydotplus library in anaconda instead of this i am getting error 'ModuleNotFoundError: No module named 'sklearn.externals.six' .this is my code:
from sklearn.tree import DecisionTreeClassifier
from IPython.display import Image
from sklearn.externals.six import StringIO
from sklearn.tree import export_graphviz
import pydot
features = list(df.columns[1:])
features
This is my error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-19-0b3416ce7fda> in <module>
1 from IPython.display import Image
---> 2 from sklearn.externals.six import StringIO
3 from sklearn.tree import export_graphviz
4 import pydot
5 ModuleNotFoundError: No module named 'sklearn.externals.six'

You can import StringIO from module six directly, no need to downgrade scikit.
from six import StringIO

Module sklearn.externals.six was removed in the scikit-learn version 0.23. To use it you have to downgrade to version 0.22. For that, you can do -
In jupyter notebook try :!pip install --upgrade scikit-learn==0.22
In terminal: pip install --upgrade scikit-learn==0.22

Related

Cannot import tensorflow_io

I am getting ModuleNotFoundError when I try to import tensorflow_io.
I tried to fix the error as described in ModuleNotFoundError: No module named 'tensorflow_io' but it didn't work with me
I did the following and I was able to have the module imported in my machine,
pip install tensorflow
pip install tensorflow_io
then in a file.py you can import them
import tensorflow as tf
import tensorflow_io as tfio
I figure you need the tensorflow module installed if you want to use the tensorflow_io.

GraphViz's executables not found error in Anaconda?

I wrote the following code to build the decision tree, but I got the following error. can you help me?
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
import pandas as pd
import numpy as np
from six import StringIO
from sklearn.tree import export_graphviz
from sklearn import tree
import pydot
from IPython.display import Image
import pydotplus
import graphviz
dot_data = StringIO()
export_graphviz(decisionTree1, out_file =dot_data, filled=True,
rounded =True, special_characters=True)
graph = pydotplus.graph_from_dot_data(dot_data.getvalue())
Image(graph.create_png())
If you are using Linux try this in cmd: sudo apt-get install graphviz
If using macOS, try this brew install graphviz
i) If on windows install it by conda conda install graphviz and add path env variables C:\Users\username\Anaconda3\Library\bin\graphviz
ii) Try to install it via conda install python-graphviz

ModuleNotFoundError: No module named 'tqdm.notebook'

I have to import tqdm using the following import command, but when I do I get an error.
Code
from tqdm.notebook import tqdm
Error
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-70-e86f188036ca> in <module>
----> 1 from tqdm.notebook import tqdm
ModuleNotFoundError: No module named 'tqdm.notebook'
tqdm is already installed in my environment but still I face this issue. How to fix this?
Try to upgrade your tqdm packgage may be it is not containing that package
pip install tqdm --upgrade
or
pip install tqdm -U

sklearn module not found in anaconda

I've been trying to import sklearn but it says that the module is not found.
my python, numpy, scipy and scikit versions are as follows as show in the conda list:
numpy 1.14.3 py36h9fa60d3_1
python 3.6.5 h0c2934d_0
scipy 1.1.0 py36h672f292_0
scikit-learn 0.19.1 py36h53aea1b_0
the error while trying to import sklearn is:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-f2461ba6e1e9> in <module>()
----> 1 from sklearn.family import model
ModuleNotFoundError: No module named 'sklearn.family'
I tried using
conda update scikit-learn
conda install scikit-learn
but I get the following results
All requested packages already installed.
how do I import sklearn then?
Although there is not skleran module, from sklearn import ... works well in PyCharm:
from sklearn.utils import resample
Try doing
conda install -c anaconda pip
pip install sklearn
AFAIK, there's no sklearn.family module. Have you tried importing other modules?
Say,
from sklearn.model_selection import TimeSeriesSplit
Does that work for you?

"load_breast_cancer" could not be loaded for iPython notebook

I tried to run from sklearn.datasets import load_breast_cancer on my iPython notebook (Python 2, Jupyter, Dato), and got the importError:
ImportError Traceback (most recent call last)
<ipython-input-12-09d44d891711> in <module>()
----> 1 from sklearn.datasets import load_breast_cancer
ImportError: cannot import name load_breast_cancer
But it works fine if I run others, e.g. from sklearn.datasets import load_diabetes, from sklearn.datasets import load_boston.
So how to import the load_breast_cancer? Thank you.
try pip install --upgrade sklearn
if you don't know where your kernel is running (if updating your machine didn't work, it seems like it is hosted somewhere else), run !pip install --upgrade sklearn in a notebook cell.

Categories

Resources