Yes, the error is in fit(X,y)

clf.fit(X,y)

---------------------------------------------------------------------------
Traceback (most recent call last):

  File "<ipython-input-77-12b5b6bd5106>", line 1, in <module>
    clf.fit(X,y)

  File "/usr/local/lib/python2.7/dist-packages/sklearn/neighbors/base.py",
line 630, in fit
    return self._fit(X)

  File "/usr/local/lib/python2.7/dist-packages/sklearn/neighbors/base.py",
line 216, in _fit
    **self.effective_metric_kwds_)

  File "binary_tree.pxi", line 1062, in
sklearn.neighbors.ball_tree.BinaryTree.__init__
(sklearn/neighbors/ball_tree.c:8037)

  File "dist_metrics.pyx", line 280, in
sklearn.neighbors.dist_metrics.DistanceMetric.get_metric
(sklearn/neighbors/dist_metrics.c:4066)

  File "dist_metrics.pyx", line 636, in
sklearn.neighbors.dist_metrics.MahalanobisDistance.__init__
(sklearn/neighbors/dist_metrics.c:7162)

  File "/usr/lib/python2.7/dist-packages/numpy/linalg/linalg.py", line 510,
in inv
    _assertRankAtLeast2(a)

  File "/usr/lib/python2.7/dist-packages/numpy/linalg/linalg.py", line 202,
in _assertRankAtLeast2
    'at least two-dimensional' % len(a.shape))

LinAlgError: 0-dimensional array given. Array must be at least
two-dimensional




On 10 July 2014 13:36, Danny Sullivan <[email protected]> wrote:

>  Hi Sheila,
>
> That looks right, I'm guessing you're getting an error when performing the
> fit, not when setting the metric. What's the error you're getting?
>
>
> On 7/10/14, 11:45 AM, Sheila the angel wrote:
>
> What is the correct way to use different  metric in KNeighborsClassifier ?
>
>  I tried this
>
>  clf = KNeighborsClassifier(metric="mahalanobis").fit(X, y)
>
>  which give me error.
>
>
>  Thanks
> --
> Sheila
>
>
> ------------------------------------------------------------------------------
> Open source business process management suite built on Java and Eclipse
> Turn processes into business applications with Bonita BPM Community Edition
> Quickly connect people, data, and systems into organized workflows
> Winner of BOSSIE, CODIE, OW2 and Gartner awardshttp://p.sf.net/sfu/Bonitasoft
>
>
>
> _______________________________________________
> Scikit-learn-general mailing 
> [email protected]https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
>
>
>
> ------------------------------------------------------------------------------
> Open source business process management suite built on Java and Eclipse
> Turn processes into business applications with Bonita BPM Community Edition
> Quickly connect people, data, and systems into organized workflows
> Winner of BOSSIE, CODIE, OW2 and Gartner awards
> http://p.sf.net/sfu/Bonitasoft
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
>
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to