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個の分類器の組み合わせはどれですか?

答えて

1

私は

text_clf0=copy.deepcopy(text_clf) 
open_multi_logit_threshold_words = text_clf0.fit(train_wordlist, train_property_labels_threshold) 

EDITをしようとするだろう:私は正確に行うにはしたくないものだリスト

text_clf_list=[copy.deepcopy(text_clf) for _ in range(16)] 

または直接

copy.deepcopy(text_c‌​lf).fit(train_wordlis‌​t, train_property_label‌​s_threshold) 
+0

を使用することができます。私は16 +モデルのためにその行をコピーする必要があるので: –

+0

1,2,3などを使用して –

+0

それは、あなたのトレースバックを投稿 – marmouset

関連する問題