I have installed anaconda. I can import panda, matplotlib but cannot import sklearn. I have installed sklearn and it also shows that it is installed,but cannot import it in jupyter. here is what it says
Try installing with the --upgrade flag.
-U, --upgrade Upgrade all specified packages to the newest available version. The handling of
dependencies depends on the upgrade-strategy used.
Use this:
!pip install -U scikit-learn
I follow the tutorials in pytorch.org
It occurs error:TensorBoard logging requires TensorBoard version 1.15 or above,but I have install TensorBoard already.
Here is the code:
#from torch.utils.tensorboard import SummaryWriter
from tensorboardX import SummaryWriter
writer = SummaryWriter('runs/fashion_mnist_experiment_1')
#get some random training images
dataiter = iter(trainloader)
images , labels = dataiter.next()
#create grid of images
img_grid = torchvision.utils.make_grid(images)
matplotlib_imshow(img_grid,one_channel=True)
writer.add_image('four_fashion_images',img_grid)
writer.add_graph(net, images)
writer.close()
Error:
ImportError Traceback (most recent call last)
<ipython-input-12-d38808675cb4> in <module>
----> 1 writer.add_graph(net, images)
2 writer.close()
~\anaconda3\envs\torch2\lib\site-packages\tensorboardX\writer.py in add_graph(self, model, input_to_model, verbose)
791
792 """
--> 793 from torch.utils.tensorboard._pytorch_graph import graph
794 self._get_file_writer().add_graph(graph(model, input_to_model, verbose))
795
~\anaconda3\envs\torch2\lib\site-packages\torch\utils\tensorboard\__init__.py in <module>
2 from distutils.version import LooseVersion
3 if not hasattr(tensorboard, '__version__') or LooseVersion(tensorboard.__version__) < LooseVersion('1.15'):
----> 4 raise ImportError('TensorBoard logging requires TensorBoard version 1.15 or above')
5 del LooseVersion
6 del tensorboard
ImportError: TensorBoard logging requires TensorBoard version 1.15 or above
Environment:
tensorboard 2.3.0 pypi_0 pypi
tensorboard-plugin-wit 1.7.0 pypi_0 pypi
tensorboardx 2.1 pypi_0 pypi
tensorflow 1.2.1 py36_0 defaults
pytorch 1.6.0 py3.6_cuda102_cudnn7_0 pytorch
torchvision 0.7.0 py36_cu102 pytorch
future 0.18.2 py36_1 defaults
protobuf 3.12.3 py36h33f27b4_0 defaults
I use from torch.utils.tensorboard import SummaryWriter at the beginning,but it occurs the error as same as above.Then I use from tensorboardX import SummaryWriter
Uninstall tensorflow, tensorboard, tensorboardx and tensorboard-plugin-wit.
Install only tensorboard with conda after that.
If this doesn't work, recreate your conda environment only with tensorboard. If you need tensorflow as well install it beforehand.
EDIT:
tensorboard-plugin-wit is a dependency of tensorboard and should be installed automatically as per their pypi description when installing tensorboard itself.
My problem was that my directory I was working in was named tensorboard, so it tried to import from the current directory instead of from the installed package.
So I suggest trying to rename the directory to see if it helps.
Do
conda uninstall tensorflow
conda uninstall tensorboard
conda uninstall tensorboardx
conda uninstall tensorboard-plugin-wit
conda uninstall cloud-tpu-client
pip uninstall tensorflow
pip uninstall tensorboard
pip uninstall tensorboardx
pip uninstall tensorboard-plugin-wit
pip uninstall cloud-tpu-client
then
conda install tensorboard
I both tried conda install and pip install, but this error still occurred when I used from torch.utils.tensorboard import SummaryWriter in an ipynb file. And I checked not hasattr(tensorboard, '__version__') or LooseVersion(tensorboard.__version__) < LooseVersion('1.15'), which both are False, meaning that it won't raise an error.
At last, I closed this ipynb file and restarted it, it worked. You should try this and no need to be struggling in reinstalling your conda env.
For my case, I had only Tensorboard without Tensorflow when I faced the error, so I had to:
conda uninstall tensorboard - this removed PyTorch Lightning as well
conda install tensorboard
conda install -c conda-forge pytorch-lightning
I am using python 3.6.3 and sklearn 0.20.3, but I am not able to print a multi-label confusion matrix.
from sklearn.metrics import multilabel_confusion_matrix
Output:
ImportError: cannot import name 'multilabel_confusion_matrix'
I also tried to install a new version of scikit-learn. But it doesn't work for me.
conda update scikit-learn
conda install scikit-learn==0.21.dev0
pip install scikit-learn==0.21.dev0
Thank you in advance for your help.
Multilabel_confusion_matrix is introduced in scikit-learn version 0.21 and most recent nightly build scikit-learn doesn't contain it. The best way to get 0.21dev is :
pip install git+http://github.com/scikit-learn/scikit-learn.git
I'm importing the sklean.impute.SimpleImputer using
from sklearn.impute import SimpleImputer
But got an error
error: No module named 'sklearn.impute'.
Installed sklearn 0.19.1 using command !pip install sklearn. How to see if it's the development version? Also, where can I access the logs?
EDIT: The pip version of scikit-learn is now 0.20+.
The impute submodule is part of scikit-learn version 0.20. It is not on pypi yet, so if you have to use that function, install the dev version of scikit-learn by pip install git+https://github.com/scikit-learn/scikit-learn.git
I wanted to use the StandardScaler class in the preprocessing package http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.StandardScaler.html#sklearn.preprocessing.StandardScaler but I keep getting an AttributeError: 'module' object has no attribute 'StandardScaler' on scikit-learn 0.13
preprocessing.__dict__ does not show StandardScaler.
I could use the LabelEncoder class in the same package.
The sklearn package in your python path is probably an old version and not the 0.13 version you installed. Try:
python -c "import sklearn; print(sklearn.__file__)"
to check whether this the expected sklearn install location or not.
To resolve duplicate installation problem I found it useful to run:
pip uninstall scikit-learn
several times until I get an error message telling explicitly that scikit-learn is not installed on the system. Then:
pip install scikit-learn
once to install the latest stable release (i.e. 0.13.1 at the time of writing).