Hi Vinay.
You need to pass the document (or rather a list of documents of length
one), not the index to predict.
Hth,
Andy
On 02/08/2013 12:32 AM, Vinay B, wrote:
Hi,
I tried again . I feel there's something wrong I'm doing with my code
so far. In any case, the print loop I added was
doc_idx = 0
for cluster_doc_filename in file_names:
# predicted_cluster = km.predict(cluster_doc_filename)
predicted_cluster = km.predict(doc_idx) #passing in an int index
print cluster_doc_filename + " " + str(predicted_cluster)
doc_idx+=1
Resulting in
Traceback (most recent call last):
File
"/home/vinayb/.IntelliJIdea12/config/plugins/python/helpers/pydev/pydevd.py",
line 1475, in <module>
debugger.run(setup['file'], None, None)
File
"/home/vinayb/.IntelliJIdea12/config/plugins/python/helpers/pydev/pydevd.py",
line 1122, in run
pydev_imports.execfile(file, globals, locals) #execute the script
File
"/home/vinayb/workspace/LearnSciKitLearn/examples/ScalableClusteringApp.py",
line 138, in <module>
predicted_cluster = km.predict(doc_idx)
File
"/usr/local/lib/python2.7/dist-packages/sklearn/cluster/k_means_.py",
line 776, in predict
X = self._check_test_data(X)
File
"/usr/local/lib/python2.7/dist-packages/sklearn/cluster/k_means_.py",
line 682, in _check_test_data
n_features, expected_n_features))
ValueError: Incorrect number of features. Got 1 features, expected 10000
On Thu, Feb 7, 2013 at 4:39 PM, Olivier Grisel
<olivier.gri...@ensta.org <mailto:olivier.gri...@ensta.org>> wrote:
There is probably an issue when accessing the `labels_` attribute if
you do `partial_fit` instead of `fit`. Instead of using label, you
should probably do another pass over the data and call `predict`
instead to compute the cluster membership info for each sample.
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
<mailto:Scikit-learn-general@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general