Text classification: value error couldn't convert str to floatsklearn: vectorizing in cross validation for text classificationsci-kit learn: Reshape your data either using X.reshape(-1, 1)Bug with CalibratedClassifierCV when using a Pipeline with TF-IDF?SVM value error text classificationLabelEncoder: TypeError: '>' not supported between instances of 'float' and 'str'Naive Bayes Classifier using Sklearn.naive_bayes.Bernoulli; how to use model to predict?Feature Mismatch with OneHotEncoder while predicting for a single instance of dataHow can using more n-gram orders decrease accuracy for Multinomial NaiveBayes classifier?Error predicting: X has n features per sample, expecting mWhile applying OneHotEncoder - Error: Could not convert Str to float: C148

How do you use the interjection for snorting?

Strange Sticky Substance on Digital Camera

To what extent is it worthwhile to report check fraud / refund scams?

What is the meaning of word 'crack' in chapter 33 of A Game of Thrones?

What exactly did this mechanic sabotage on the American Airlines 737, and how dangerous was it?

Meaning of 'ran' in German?

Two trains move towards each other, a bird moves between them. How many trips can the bird make?

Do we have any particular tonal center in mind when we are NOT listening music?

How can this Stack Exchange site have an animated favicon?

Why does this image of Jupiter look so strange?

A high quality contribution but an annoying error is present in my published article

Are lawyers allowed to come to agreements with opposing lawyers without the client's knowledge or consent?

Can a broken/split chain be reassembled?

Safe to use 220V electric clothes dryer when building has been bridged down to 110V?

Can Northern Ireland's border issue be solved by repartition?

Why did UK NHS pay for homeopathic treatments?

My Project Manager does not accept carry-over in Scrum, Is that normal?

Going to France with limited French for a day

Is it impolite to ask for an in-flight catalogue with no intention of buying?

Organisational search option

Why are there two fundamental laws of logic?

2000s Animated TV show where teenagers could physically go into a virtual world

Performance for simple code that converts a RGB tuple to hex string

Guitar tuning (EADGBE), "perfect" fourths?



Text classification: value error couldn't convert str to float


sklearn: vectorizing in cross validation for text classificationsci-kit learn: Reshape your data either using X.reshape(-1, 1)Bug with CalibratedClassifierCV when using a Pipeline with TF-IDF?SVM value error text classificationLabelEncoder: TypeError: '>' not supported between instances of 'float' and 'str'Naive Bayes Classifier using Sklearn.naive_bayes.Bernoulli; how to use model to predict?Feature Mismatch with OneHotEncoder while predicting for a single instance of dataHow can using more n-gram orders decrease accuracy for Multinomial NaiveBayes classifier?Error predicting: X has n features per sample, expecting mWhile applying OneHotEncoder - Error: Could not convert Str to float: C148






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















Input for random forest classifier trained model for text classification



I am not able to know what should be the input for the trained model after opening the model from the pickle file.



with open('text_classifier', 'rb') as training_model:
model = pickle.load(training_model)
for message in text:
message1 = [str(message)]
pred = model.predict(message1)
list.append(pred)
return list


Expected output: Non political



Actual output :




ValueError: could not convert string to float: 'RT @ScotNational The
witness admitted that not all damage inflicted on police cars was
caused











share|improve this question
































    2















    Input for random forest classifier trained model for text classification



    I am not able to know what should be the input for the trained model after opening the model from the pickle file.



    with open('text_classifier', 'rb') as training_model:
    model = pickle.load(training_model)
    for message in text:
    message1 = [str(message)]
    pred = model.predict(message1)
    list.append(pred)
    return list


    Expected output: Non political



    Actual output :




    ValueError: could not convert string to float: 'RT @ScotNational The
    witness admitted that not all damage inflicted on police cars was
    caused











    share|improve this question




























      2












      2








      2








      Input for random forest classifier trained model for text classification



      I am not able to know what should be the input for the trained model after opening the model from the pickle file.



      with open('text_classifier', 'rb') as training_model:
      model = pickle.load(training_model)
      for message in text:
      message1 = [str(message)]
      pred = model.predict(message1)
      list.append(pred)
      return list


      Expected output: Non political



      Actual output :




      ValueError: could not convert string to float: 'RT @ScotNational The
      witness admitted that not all damage inflicted on police cars was
      caused











      share|improve this question
















      Input for random forest classifier trained model for text classification



      I am not able to know what should be the input for the trained model after opening the model from the pickle file.



      with open('text_classifier', 'rb') as training_model:
      model = pickle.load(training_model)
      for message in text:
      message1 = [str(message)]
      pred = model.predict(message1)
      list.append(pred)
      return list


      Expected output: Non political



      Actual output :




      ValueError: could not convert string to float: 'RT @ScotNational The
      witness admitted that not all damage inflicted on police cars was
      caused








      scikit-learn word-embedding






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 29 at 4:50









      Venkatachalam N

      6,6376 gold badges15 silver badges41 bronze badges




      6,6376 gold badges15 silver badges41 bronze badges










      asked Mar 28 at 16:26









      Chetan ManjuChetan Manju

      111 bronze badge




      111 bronze badge

























          1 Answer
          1






          active

          oldest

          votes


















          1
















          You need to encode the text as numbers. No machine algorithm can process text directly.



          More precisely, you need to use a word embedding (the same used for training the model). Example of common word embeddings are Word2vec, TF-IDF.



          I suggest you to play with sklearn.feature_extraction.text.CountVectorizer and sklearn.feature_extraction.text.TfidfTransformer to familiarize yourself with the concept of embedding.



          However, if you do not use the same embedding as the one used to train the model you load, there is no way you will obtain good results.






          share|improve this answer

























          • thank you sir can i get a link which will help me for the same

            – Chetan Manju
            Mar 30 at 14:15













          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/4.0/"u003ecc by-sa 4.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%2f55402560%2ftext-classification-value-error-couldnt-convert-str-to-float%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 need to encode the text as numbers. No machine algorithm can process text directly.



          More precisely, you need to use a word embedding (the same used for training the model). Example of common word embeddings are Word2vec, TF-IDF.



          I suggest you to play with sklearn.feature_extraction.text.CountVectorizer and sklearn.feature_extraction.text.TfidfTransformer to familiarize yourself with the concept of embedding.



          However, if you do not use the same embedding as the one used to train the model you load, there is no way you will obtain good results.






          share|improve this answer

























          • thank you sir can i get a link which will help me for the same

            – Chetan Manju
            Mar 30 at 14:15















          1
















          You need to encode the text as numbers. No machine algorithm can process text directly.



          More precisely, you need to use a word embedding (the same used for training the model). Example of common word embeddings are Word2vec, TF-IDF.



          I suggest you to play with sklearn.feature_extraction.text.CountVectorizer and sklearn.feature_extraction.text.TfidfTransformer to familiarize yourself with the concept of embedding.



          However, if you do not use the same embedding as the one used to train the model you load, there is no way you will obtain good results.






          share|improve this answer

























          • thank you sir can i get a link which will help me for the same

            – Chetan Manju
            Mar 30 at 14:15













          1














          1










          1









          You need to encode the text as numbers. No machine algorithm can process text directly.



          More precisely, you need to use a word embedding (the same used for training the model). Example of common word embeddings are Word2vec, TF-IDF.



          I suggest you to play with sklearn.feature_extraction.text.CountVectorizer and sklearn.feature_extraction.text.TfidfTransformer to familiarize yourself with the concept of embedding.



          However, if you do not use the same embedding as the one used to train the model you load, there is no way you will obtain good results.






          share|improve this answer













          You need to encode the text as numbers. No machine algorithm can process text directly.



          More precisely, you need to use a word embedding (the same used for training the model). Example of common word embeddings are Word2vec, TF-IDF.



          I suggest you to play with sklearn.feature_extraction.text.CountVectorizer and sklearn.feature_extraction.text.TfidfTransformer to familiarize yourself with the concept of embedding.



          However, if you do not use the same embedding as the one used to train the model you load, there is no way you will obtain good results.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 28 at 19:24









          EskappEskapp

          1,95114 silver badges27 bronze badges




          1,95114 silver badges27 bronze badges















          • thank you sir can i get a link which will help me for the same

            – Chetan Manju
            Mar 30 at 14:15

















          • thank you sir can i get a link which will help me for the same

            – Chetan Manju
            Mar 30 at 14:15
















          thank you sir can i get a link which will help me for the same

          – Chetan Manju
          Mar 30 at 14:15





          thank you sir can i get a link which will help me for the same

          – Chetan Manju
          Mar 30 at 14:15




















          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%2f55402560%2ftext-classification-value-error-couldnt-convert-str-to-float%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

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현