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;
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
add a comment
|
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
add a comment
|
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
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
scikit-learn word-embedding
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
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
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.
thank you sir can i get a link which will help me for the same
– Chetan Manju
Mar 30 at 14:15
add a comment
|
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
thank you sir can i get a link which will help me for the same
– Chetan Manju
Mar 30 at 14:15
add a comment
|
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.
thank you sir can i get a link which will help me for the same
– Chetan Manju
Mar 30 at 14:15
add a comment
|
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.
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.
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
add a comment
|
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
add a comment
|
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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