0

I am trying to visualize some data. However, I am receiving the following error:

Traceback (most recent call last): File "/Users/usrname/PycharmProjects/MachineLearning/dddd.py", line 4, in <module> from sklearn.datasets import load_iris File "/usr/local/lib/python2.7/site-packages/sklearn/__init__.py", line 32, in <module> from .base import clone File "/usr/local/lib/python2.7/site-packages/sklearn/base.py", line 10, in <module> from scipy import sparse ImportError: No module named scipy 

Below, there is the code to visualize the data.

from matplotlib import pyplot as plt from sklearn.datasets import load_iris import numpy as np # We load the data with load_iris from sklearn data = load_iris() features = data['data'] feature_names = data['feature_names'] target = data['target'] for t,marker,c in zip(xrange(3),">ox","rgb"): # We plot each class on its own to get different colored markers plt.scatter(features[target == t,0],features[target == t,1],marker=marker,c=c) 

I am using the the Python 2.7, Mac OS "Mavericks".

5
  • 2
    How did you install sklearn? It evidently requires scipy, which you may also need to install. Commented Dec 24, 2013 at 17:53
  • I've installed scipy via sudo pip install scipy Commented Dec 24, 2013 at 22:17
  • And can you run from scipy import sparse directly in the interpreter? Commented Dec 24, 2013 at 22:50
  • unfortunately, I can't. Commented Dec 25, 2013 at 0:09
  • Sorry, do you mean you can't try, or it gives the same error? If the latter, you will have to try reinstalling scipy, as sklearn won't work without it Commented Dec 25, 2013 at 16:07

1 Answer 1

1

Check if the sckit-learn is working properly or not.

 nosetests -v sklearn 

if it shows error try installing first Scipy by

pip install git+http://github.com/scipy/scipy/ 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.