“Unknown label type” with numpy and scikit











up vote
0
down vote

favorite












X = np.array(...,dtype=np.float64).astype(np.float)
y = np.array(...,dtype=np.float64).astype(np.float)

print(X)
[[-0.5 0. ]
[ 0. 0. ]
[ 0. 0. ]
[ 0. 0. ]
[ 0. -3.5]
[-3.5 -3.5]
[-3.5 -2. ]
[-2. 0. ]
[ 0. 0. ]
[ 0. -3. ]]
print(y)
[-3.5 -3.5 -3.5 -3.5 -3.5 -2. -3. -3. -3. 1. ]
(10, 2)
(10,)


from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(X, Y)


No matter what I do I get



Traceback (most recent call last):
File "scripts/wave-pool.py", line 174, in <module>
clf.fit(X, y)
File "/home/ben/.local/lib/python2.7/site-packages/sklearn/naive_bayes.py", line 192, in fit
sample_weight=sample_weight)
File "/home/ben/.local/lib/python2.7/site-packages/sklearn/naive_bayes.py", line 355, in _partial_fit
if _check_partial_fit_first_call(self, classes):
File "/home/ben/.local/lib/python2.7/site-packages/sklearn/utils/multiclass.py", line 320, in _check_partial_fit_first_call
clf.classes_ = unique_labels(classes)
File "/home/ben/.local/lib/python2.7/site-packages/sklearn/utils/multiclass.py", line 96, in unique_labels
raise ValueError("Unknown label type: %s" % repr(ys))
ValueError: Unknown label type: (array([-3.5, -3. , -2. , 1. ]),)









share|improve this question


















  • 1




    Apparently it doesn't like using floats as 'labels'. Integers work. You may need to dig into the sklearn docs to learn what constitutes valid learning data.
    – hpaulj
    yesterday










  • Classifier != regressor.
    – Matthieu Brucher
    yesterday










  • @hpaulj Ah that makes sense. Converting to strings for equality would be more appropriate for classes
    – Ben
    6 hours ago















up vote
0
down vote

favorite












X = np.array(...,dtype=np.float64).astype(np.float)
y = np.array(...,dtype=np.float64).astype(np.float)

print(X)
[[-0.5 0. ]
[ 0. 0. ]
[ 0. 0. ]
[ 0. 0. ]
[ 0. -3.5]
[-3.5 -3.5]
[-3.5 -2. ]
[-2. 0. ]
[ 0. 0. ]
[ 0. -3. ]]
print(y)
[-3.5 -3.5 -3.5 -3.5 -3.5 -2. -3. -3. -3. 1. ]
(10, 2)
(10,)


from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(X, Y)


No matter what I do I get



Traceback (most recent call last):
File "scripts/wave-pool.py", line 174, in <module>
clf.fit(X, y)
File "/home/ben/.local/lib/python2.7/site-packages/sklearn/naive_bayes.py", line 192, in fit
sample_weight=sample_weight)
File "/home/ben/.local/lib/python2.7/site-packages/sklearn/naive_bayes.py", line 355, in _partial_fit
if _check_partial_fit_first_call(self, classes):
File "/home/ben/.local/lib/python2.7/site-packages/sklearn/utils/multiclass.py", line 320, in _check_partial_fit_first_call
clf.classes_ = unique_labels(classes)
File "/home/ben/.local/lib/python2.7/site-packages/sklearn/utils/multiclass.py", line 96, in unique_labels
raise ValueError("Unknown label type: %s" % repr(ys))
ValueError: Unknown label type: (array([-3.5, -3. , -2. , 1. ]),)









share|improve this question


















  • 1




    Apparently it doesn't like using floats as 'labels'. Integers work. You may need to dig into the sklearn docs to learn what constitutes valid learning data.
    – hpaulj
    yesterday










  • Classifier != regressor.
    – Matthieu Brucher
    yesterday










  • @hpaulj Ah that makes sense. Converting to strings for equality would be more appropriate for classes
    – Ben
    6 hours ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











X = np.array(...,dtype=np.float64).astype(np.float)
y = np.array(...,dtype=np.float64).astype(np.float)

print(X)
[[-0.5 0. ]
[ 0. 0. ]
[ 0. 0. ]
[ 0. 0. ]
[ 0. -3.5]
[-3.5 -3.5]
[-3.5 -2. ]
[-2. 0. ]
[ 0. 0. ]
[ 0. -3. ]]
print(y)
[-3.5 -3.5 -3.5 -3.5 -3.5 -2. -3. -3. -3. 1. ]
(10, 2)
(10,)


from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(X, Y)


No matter what I do I get



Traceback (most recent call last):
File "scripts/wave-pool.py", line 174, in <module>
clf.fit(X, y)
File "/home/ben/.local/lib/python2.7/site-packages/sklearn/naive_bayes.py", line 192, in fit
sample_weight=sample_weight)
File "/home/ben/.local/lib/python2.7/site-packages/sklearn/naive_bayes.py", line 355, in _partial_fit
if _check_partial_fit_first_call(self, classes):
File "/home/ben/.local/lib/python2.7/site-packages/sklearn/utils/multiclass.py", line 320, in _check_partial_fit_first_call
clf.classes_ = unique_labels(classes)
File "/home/ben/.local/lib/python2.7/site-packages/sklearn/utils/multiclass.py", line 96, in unique_labels
raise ValueError("Unknown label type: %s" % repr(ys))
ValueError: Unknown label type: (array([-3.5, -3. , -2. , 1. ]),)









share|improve this question













X = np.array(...,dtype=np.float64).astype(np.float)
y = np.array(...,dtype=np.float64).astype(np.float)

print(X)
[[-0.5 0. ]
[ 0. 0. ]
[ 0. 0. ]
[ 0. 0. ]
[ 0. -3.5]
[-3.5 -3.5]
[-3.5 -2. ]
[-2. 0. ]
[ 0. 0. ]
[ 0. -3. ]]
print(y)
[-3.5 -3.5 -3.5 -3.5 -3.5 -2. -3. -3. -3. 1. ]
(10, 2)
(10,)


from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(X, Y)


No matter what I do I get



Traceback (most recent call last):
File "scripts/wave-pool.py", line 174, in <module>
clf.fit(X, y)
File "/home/ben/.local/lib/python2.7/site-packages/sklearn/naive_bayes.py", line 192, in fit
sample_weight=sample_weight)
File "/home/ben/.local/lib/python2.7/site-packages/sklearn/naive_bayes.py", line 355, in _partial_fit
if _check_partial_fit_first_call(self, classes):
File "/home/ben/.local/lib/python2.7/site-packages/sklearn/utils/multiclass.py", line 320, in _check_partial_fit_first_call
clf.classes_ = unique_labels(classes)
File "/home/ben/.local/lib/python2.7/site-packages/sklearn/utils/multiclass.py", line 96, in unique_labels
raise ValueError("Unknown label type: %s" % repr(ys))
ValueError: Unknown label type: (array([-3.5, -3. , -2. , 1. ]),)






numpy scikit-learn






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









Ben

7,55721014




7,55721014








  • 1




    Apparently it doesn't like using floats as 'labels'. Integers work. You may need to dig into the sklearn docs to learn what constitutes valid learning data.
    – hpaulj
    yesterday










  • Classifier != regressor.
    – Matthieu Brucher
    yesterday










  • @hpaulj Ah that makes sense. Converting to strings for equality would be more appropriate for classes
    – Ben
    6 hours ago














  • 1




    Apparently it doesn't like using floats as 'labels'. Integers work. You may need to dig into the sklearn docs to learn what constitutes valid learning data.
    – hpaulj
    yesterday










  • Classifier != regressor.
    – Matthieu Brucher
    yesterday










  • @hpaulj Ah that makes sense. Converting to strings for equality would be more appropriate for classes
    – Ben
    6 hours ago








1




1




Apparently it doesn't like using floats as 'labels'. Integers work. You may need to dig into the sklearn docs to learn what constitutes valid learning data.
– hpaulj
yesterday




Apparently it doesn't like using floats as 'labels'. Integers work. You may need to dig into the sklearn docs to learn what constitutes valid learning data.
– hpaulj
yesterday












Classifier != regressor.
– Matthieu Brucher
yesterday




Classifier != regressor.
– Matthieu Brucher
yesterday












@hpaulj Ah that makes sense. Converting to strings for equality would be more appropriate for classes
– Ben
6 hours ago




@hpaulj Ah that makes sense. Converting to strings for equality would be more appropriate for classes
– Ben
6 hours ago












1 Answer
1






active

oldest

votes

















up vote
0
down vote













"doesn't like using floats as 'labels'. Integers work" hpaulj






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53349301%2funknown-label-type-with-numpy-and-scikit%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    "doesn't like using floats as 'labels'. Integers work" hpaulj






    share|improve this answer

























      up vote
      0
      down vote













      "doesn't like using floats as 'labels'. Integers work" hpaulj






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        "doesn't like using floats as 'labels'. Integers work" hpaulj






        share|improve this answer












        "doesn't like using floats as 'labels'. Integers work" hpaulj







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 3 hours ago









        Ben

        7,55721014




        7,55721014






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53349301%2funknown-label-type-with-numpy-and-scikit%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Ottavio Pratesi

            Tricia Helfer

            15 giugno