[Tutor] HELP- Regarding working with python
Marc Tompkins
marc.tompkins at gmail.com
Fri Jan 18 09:07:27 CET 2013
On Thu, Jan 17, 2013 at 10:11 PM, Gayathri S <gayathri.s112 at gmail.com>wrote:
> >>> import numpy as np
> >>> import matplotlib.pyplot as plt
> >>> import mlpy
> >>> np.random.seed(0)
> >>> mean,cov,n=[0,0],[[1,1],[1,1.5]],100
> >>> x=np.random.multivariate_normal(mean,cov,n)
> >>> pca.learn(x)
> Traceback (most recent call last):
> File "<interactive input>", line 1, in <module>
> NameError: name 'pca' is not defined
> >>>
> would you please help me in finding the error...? what was my fault? how
> could i use PCA in python..?
>
> The error means exactly what it says: you've referred to "pca", but you
haven't told Python what "pca" is.
I don't know the actual name of the PCA module you're using, but you need
to import it the same way you've imported the other packages:
- if it's called simply "pca", then just write "import pca"
- if it has some other, slightly longer name, and you want to shorten it
(as you did with "numpy", shortening it to "np"), then: "import longPCAname
as pca"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130118/9ea7962f/attachment.html>
More information about the Tutor
mailing list