Unknown label type: array in sklearn












0















I have problems with sklearn MLPClassifier fit and I receive this error:



this is my dataset:



        x               y           z
0 -35.997271 -16.594561 4.142350
1 -1.587584 -6.526561 0.212667
2 -15.775675 -30.170914 0.370804
3 -22.165420 -0.892974 0.161097
4 -13.913515 -16.396032 9.223847


I have splited the X and y train and test data:



x = np.array(df.drop(['z'],1))
y = np.array(df['z'])
x = preprocessing.scale(x)
X_train, X_test, y_train, y_test = cross_validation.train_test_split(x,y, test_size=0.2)


and finally run the mlpclassifier and fit function:



mlp = MLPClassifier(hidden_layer_sizes=(13,13,13), max_iter=500)
mlp.fit(X_train, y_train)


but I received this error:



Unknown label type: (array([ 2.36,  9.88,  6.93,  1.27,  6.64,  4.7 ,  4.72,  4.66, 10.45,
9.78, 3.97, 10.25, 0.45, 0.07, 7.79, 3.43, 0.71, 2.82,
7.67, 0.43, 4.48, 8.62, 0.56, 3.57, 6.85, 2.75, 3.37,
3.24, 2.41, 0.31, 5.51, 6.13, 9.48, 2.02, 0.13, 8.8 ,
0.37, 5.44, 5.05, 7.96, 4.56, 6.87, 2.93, 8.86, 10.2 ,
1.61, 4.26, 4.5 , 6.11, 10.05, 2.1 , 5.82, 2.69, 7.13,
1.47, 1.79, 1.86, 7.2 , 0.5 , 0.58, 0.16, 5.78, 6.02,
0.97, 7.05, 6.3 , 0.97, 5.04, 9.51, 2.88, 3.89, 8.82,
0.09, 8.37, 1.46, 9.22, 0.09, 4.8 , 0. , 6.16]),)


any ideas for solving this problem?










share|improve this question























  • You are trying to predict continuous real-values with a classifier. Use a regressor instead.

    – Vivek Kumar
    Nov 22 '18 at 7:18
















0















I have problems with sklearn MLPClassifier fit and I receive this error:



this is my dataset:



        x               y           z
0 -35.997271 -16.594561 4.142350
1 -1.587584 -6.526561 0.212667
2 -15.775675 -30.170914 0.370804
3 -22.165420 -0.892974 0.161097
4 -13.913515 -16.396032 9.223847


I have splited the X and y train and test data:



x = np.array(df.drop(['z'],1))
y = np.array(df['z'])
x = preprocessing.scale(x)
X_train, X_test, y_train, y_test = cross_validation.train_test_split(x,y, test_size=0.2)


and finally run the mlpclassifier and fit function:



mlp = MLPClassifier(hidden_layer_sizes=(13,13,13), max_iter=500)
mlp.fit(X_train, y_train)


but I received this error:



Unknown label type: (array([ 2.36,  9.88,  6.93,  1.27,  6.64,  4.7 ,  4.72,  4.66, 10.45,
9.78, 3.97, 10.25, 0.45, 0.07, 7.79, 3.43, 0.71, 2.82,
7.67, 0.43, 4.48, 8.62, 0.56, 3.57, 6.85, 2.75, 3.37,
3.24, 2.41, 0.31, 5.51, 6.13, 9.48, 2.02, 0.13, 8.8 ,
0.37, 5.44, 5.05, 7.96, 4.56, 6.87, 2.93, 8.86, 10.2 ,
1.61, 4.26, 4.5 , 6.11, 10.05, 2.1 , 5.82, 2.69, 7.13,
1.47, 1.79, 1.86, 7.2 , 0.5 , 0.58, 0.16, 5.78, 6.02,
0.97, 7.05, 6.3 , 0.97, 5.04, 9.51, 2.88, 3.89, 8.82,
0.09, 8.37, 1.46, 9.22, 0.09, 4.8 , 0. , 6.16]),)


any ideas for solving this problem?










share|improve this question























  • You are trying to predict continuous real-values with a classifier. Use a regressor instead.

    – Vivek Kumar
    Nov 22 '18 at 7:18














0












0








0








I have problems with sklearn MLPClassifier fit and I receive this error:



this is my dataset:



        x               y           z
0 -35.997271 -16.594561 4.142350
1 -1.587584 -6.526561 0.212667
2 -15.775675 -30.170914 0.370804
3 -22.165420 -0.892974 0.161097
4 -13.913515 -16.396032 9.223847


I have splited the X and y train and test data:



x = np.array(df.drop(['z'],1))
y = np.array(df['z'])
x = preprocessing.scale(x)
X_train, X_test, y_train, y_test = cross_validation.train_test_split(x,y, test_size=0.2)


and finally run the mlpclassifier and fit function:



mlp = MLPClassifier(hidden_layer_sizes=(13,13,13), max_iter=500)
mlp.fit(X_train, y_train)


but I received this error:



Unknown label type: (array([ 2.36,  9.88,  6.93,  1.27,  6.64,  4.7 ,  4.72,  4.66, 10.45,
9.78, 3.97, 10.25, 0.45, 0.07, 7.79, 3.43, 0.71, 2.82,
7.67, 0.43, 4.48, 8.62, 0.56, 3.57, 6.85, 2.75, 3.37,
3.24, 2.41, 0.31, 5.51, 6.13, 9.48, 2.02, 0.13, 8.8 ,
0.37, 5.44, 5.05, 7.96, 4.56, 6.87, 2.93, 8.86, 10.2 ,
1.61, 4.26, 4.5 , 6.11, 10.05, 2.1 , 5.82, 2.69, 7.13,
1.47, 1.79, 1.86, 7.2 , 0.5 , 0.58, 0.16, 5.78, 6.02,
0.97, 7.05, 6.3 , 0.97, 5.04, 9.51, 2.88, 3.89, 8.82,
0.09, 8.37, 1.46, 9.22, 0.09, 4.8 , 0. , 6.16]),)


any ideas for solving this problem?










share|improve this question














I have problems with sklearn MLPClassifier fit and I receive this error:



this is my dataset:



        x               y           z
0 -35.997271 -16.594561 4.142350
1 -1.587584 -6.526561 0.212667
2 -15.775675 -30.170914 0.370804
3 -22.165420 -0.892974 0.161097
4 -13.913515 -16.396032 9.223847


I have splited the X and y train and test data:



x = np.array(df.drop(['z'],1))
y = np.array(df['z'])
x = preprocessing.scale(x)
X_train, X_test, y_train, y_test = cross_validation.train_test_split(x,y, test_size=0.2)


and finally run the mlpclassifier and fit function:



mlp = MLPClassifier(hidden_layer_sizes=(13,13,13), max_iter=500)
mlp.fit(X_train, y_train)


but I received this error:



Unknown label type: (array([ 2.36,  9.88,  6.93,  1.27,  6.64,  4.7 ,  4.72,  4.66, 10.45,
9.78, 3.97, 10.25, 0.45, 0.07, 7.79, 3.43, 0.71, 2.82,
7.67, 0.43, 4.48, 8.62, 0.56, 3.57, 6.85, 2.75, 3.37,
3.24, 2.41, 0.31, 5.51, 6.13, 9.48, 2.02, 0.13, 8.8 ,
0.37, 5.44, 5.05, 7.96, 4.56, 6.87, 2.93, 8.86, 10.2 ,
1.61, 4.26, 4.5 , 6.11, 10.05, 2.1 , 5.82, 2.69, 7.13,
1.47, 1.79, 1.86, 7.2 , 0.5 , 0.58, 0.16, 5.78, 6.02,
0.97, 7.05, 6.3 , 0.97, 5.04, 9.51, 2.88, 3.89, 8.82,
0.09, 8.37, 1.46, 9.22, 0.09, 4.8 , 0. , 6.16]),)


any ideas for solving this problem?







arrays scikit-learn valueerror






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 22:51









Morteza RahbarMorteza Rahbar

1




1













  • You are trying to predict continuous real-values with a classifier. Use a regressor instead.

    – Vivek Kumar
    Nov 22 '18 at 7:18



















  • You are trying to predict continuous real-values with a classifier. Use a regressor instead.

    – Vivek Kumar
    Nov 22 '18 at 7:18

















You are trying to predict continuous real-values with a classifier. Use a regressor instead.

– Vivek Kumar
Nov 22 '18 at 7:18





You are trying to predict continuous real-values with a classifier. Use a regressor instead.

– Vivek Kumar
Nov 22 '18 at 7:18












1 Answer
1






active

oldest

votes


















1














You run MLPClassifier when your output seems to be a continuous variable. So either use MLPRegressor or replace outputs with class labels.






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',
    autoActivateHeartbeat: false,
    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%2f53421542%2funknown-label-type-array-in-sklearn%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









    1














    You run MLPClassifier when your output seems to be a continuous variable. So either use MLPRegressor or replace outputs with class labels.






    share|improve this answer




























      1














      You run MLPClassifier when your output seems to be a continuous variable. So either use MLPRegressor or replace outputs with class labels.






      share|improve this answer


























        1












        1








        1







        You run MLPClassifier when your output seems to be a continuous variable. So either use MLPRegressor or replace outputs with class labels.






        share|improve this answer













        You run MLPClassifier when your output seems to be a continuous variable. So either use MLPRegressor or replace outputs with class labels.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 5:49









        avchauzovavchauzov

        69437




        69437






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421542%2funknown-label-type-array-in-sklearn%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

            Wiesbaden

            Marschland

            Dieringhausen