#Help with an error

65 messages · Page 1 of 1 (latest)

dreamy merlin
#

Please double check that the object lg corresponds to LogisticRegression

muted night
#

i checked it

fiery hound
#

Look, this is not a regression task it's a classification task

#

regression would be for predicting an item in a sequence or continuous function. Detecting emotion is more along the lines of classification

#

You even have it in your code as "label"

muted night
#

so what should I do ?

fiery hound
#

what is the model you are training to classify?

muted night
#

Logistic Regression

fiery hound
#

change it to a classifier

#

what is the model you import?

#

Give the import line + model initialization code

muted night
fiery hound
#

Ok.... that's not helpful

muted night
fiery hound
#

still not helpful

#

you loaded the lg variable from a pkl file. That doesn't tell me what the model is

muted night
fiery hound
#

the model could be a SVM, KNN, random tree/forest, MLP/NN, etc

fiery hound
#

Looking at your error, go back and make sure your df_test is the same as your df_train after you transform both with the TF-IDF vectorizer

muted night
#

oh okay

fiery hound
#

the error you gave points to the vectorizor calling predict() which is not right

muted night
#

yep but it says tfidfvectorizer has no attribute predict

fiery hound
#

yes, that's correct

muted night
#

but predict is being used with logistic regression model

fiery hound
#

right

#

lg should be the LogisticRegression model -> which does have .predict()

muted night
#

yup

fiery hound
#

but for some reason, the program is seeing lg as a TFIDFVectorizer -> which does NOT have .predict()

muted night
#

yeah

fiery hound
#

What happens when you output type(tf_test) and type(tf_train)?

#

I ask because you use the vectorizor on those datasets differently.

#

you fit_transform on train data but only transform on the test data

muted night
fiery hound
#

for both?

muted night
#

yup

fiery hound
#

what about type(lg)?

muted night
fiery hound
#

Hmmm.....

#

@muted night do the same for inpvector

#

It's odd that the part that's throwing an error is a function you never call in your code.

fiery hound
#

that's interesting

#

why is it a list?

#

when the other data is a csr matrix?

muted night
muted night
fiery hound
#

Right but after your tfidf vectorizer transforms the text, it should be in csr/csc matrix

muted night
#

oh wait i checked type of inp sorry

fiery hound
#

Yeah but you have to print the type of inpvector from within the function

#

otherwise inpvector is going to be None because the variable is out of scope (of the function)

muted night
#

<class 'scipy.sparse._csr.csr_matrix'>

#

its a matrix

fiery hound
#

Good

#

and do the same thing. Call type(lg) from within the function

muted night
#

<class 'sklearn.linear_model._logistic.LogisticRegression'>

fiery hound
#

Hmmm... Rerun it all again

muted night
#

okayy

fiery hound
#

because in your screenshot, you should have gotten the error again when you called your function but it ran just fine.

muted night
#

done

fiery hound
#

Any error messages?

muted night
#

nope

fiery hound
#

Then I think you're all set