![]() In the line classifier = clf.fit(list(X), y), I get the following error: Traceback (most recent call last):įile "C:\Users\User\AppData\Local\JetBrains\Toolbox\apps\P圜harm-P\ch-0\191.7141.48\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile Finally, I list-enise everything in the train_classifier function, which supposedly should help. I make sure to apply transformations to the test data, too, so there can be no inconsistency there. Finally, I process the text using the spaCy settings found in this tutorial. My code firstly splits up the categorical values (which are comma-delimited), before running them through MultiLabelBinarizer(). Train, test = represent(df, test_data,, , )Īs you can see, there are text values, number values and categorical values. Test_data = pd.DataFrame(pd.read_csv("test.csv", header=0)) X = ]) for i in range(1, len(train_docs))]ĭf = pd.DataFrame(pd.read_csv("testdata.csv", header=0)) Print("preprocessing completed successfully")ĭef train_classifier(train_docs, classAxis):Ĭlf = OneVsRestClassifier(LogisticRegression(solver='saga')) Vec = TfidfVectorizer(tokenizer=tokenizeText, ngram_range=(1, 1))ĭoc_train = vec.transform(doc_train).todense()ĭoc_test = vec.transform(doc_test).todense() Print("numbers scaled using StandardScaler()")ĭoc_train = ansform(doc_train)ĭoc_test = ansform(doc_test) Print("categorical columns encoded using MultiLabelBinarizer()") Self.encoder = MultiLabelBinarizer(*args, **kwargs)ĭef represent(rd, ed, number, category, text):ĭoc_train = ]ĭoc_test = ]įor row in range(len(doc_train)):ĭoc_train = transformed_rĭoc_test = transformed_e lemma_ for tok in tokens if tok not in SYMBOLS] Lemmas.append(tok.lemma_.lower().strip() if tok.lemma_ != "-PRON-" else tok.lower_) I have the following code: nlp = spacy.load('en_core_web_sm')Ĭlass CleanTextTransformer(TransformerMixin):ĭef transform(self, X, **transform_params): Currently working on Repost : an application that selects and reposts your best content automatically on Social Media.I have already seen this, this and this question, but none of the suggestions seemed to fix my problem (so I have reverted them). Jean-Christophe Lavocat's Picture Jean-Christophe Lavocat In order to help numpy to accept your vector… tell it it’s not a vector :īy doing this you change de dtype of your array, and it can accept even personnal classes. This is my own solution, so if helped you, I would be very glad :-D Instead, here is the solution I found after 4 hours looking everywhere on the web… finding nothing. ![]() ![]() Ok, then you can try to change the second value 0.5 to. It doesn’t like the fact you give it table with different sizes. The problem is that numpy is made to calculate vectors and arrays. I first didn’t notice the problem because I wasn’t using the ‘ array‘ constructor, but when I tried to append some value to my initial vector, I got the error : ValueError: setting an array element with sequence.Įven the simple construction : array(,0.5)]) would give the error. With the basic syntax, it was impossible. In my case I was trying to create an array of the following shape : You have struggled during hours and hours to understand why you got this damned error while compiling a complex array structure? I did. World Hacks (Home) ☰ Menu Numpy error – ValueError: setting an array element with sequence
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |