0
我有一個Pipeline
對象,我想適合不同的訓練和測試標籤組合,因此使用fit
對象創建不同的預測。但我相信fit
使用相同的分類器對象擺脫了以前的fit
對象。對不同擬合模型重複使用邏輯迴歸對象
我的代碼的一個例子是:
text_clf = Pipeline([('vect', CountVectorizer(analyzer="word",tokenizer=None,preprocessor=None,stop_words=None,max_features=5000)),
('tfidf', TfidfTransformer(use_idf=True,norm='l2',sublinear_tf=True)),
('clf',LogisticRegression(solver='newton-cg',class_weight='balanced', multi_class='multinomial',fit_intercept=True),
)])
print "Fitting the open multinomial BoW logistic regression model for probability models...\n"
open_multi_logit_words = text_clf.fit(train_wordlist, train_property_labels)
print "Fitting the open multinomial BoW logistic regression model w/ ",threshold," MAPE threshold...\n"
open_multi_logit_threshold_words = (text_clf.copy.deepcopy()).fit(train_wordlist, train_property_labels_threshold)
然而,分類對象沒有deepcopy()
方法。我怎樣才能達到我所需要的,而不必定義:
text_clf_open_multi_logit = Pipeline([('vect', CountVectorizer(analyzer="word",tokenizer=None,preprocessor=None,stop_words=None,max_features=5000)),
('tfidf', TfidfTransformer(use_idf=True,norm='l2',sublinear_tf=True)),
('clf',LogisticRegression(solver='newton-cg',class_weight='balanced', multi_class='multinomial',fit_intercept=True),
)])
對於我所有的16個分類組合?
這就是我恰恰不想做的事。因爲我必須複製該行16 +型號:) –
並使用1,2,3等 –
它確實發佈你的追蹤 – marmouset