Anaconda错误:AttributeError:无法获取属性

时间:2018-03-21 05:31:13

标签: python scikit-learn nlp anaconda

def fit(self):
    tfidf = TfidfVectorizer(strip_accents=None,lowercase=False,
    preprocessor=self.preprocessor)
    param_grid = [{'vect__ngram_range' : [(1,1)],
                  'vect__stop_words':[self.stop,None],
                  'vect__tokenizer':[self.tokenizer,self.tokenizer_porter],
                  'clf__C':[1.0,10.0,100.0]},
                  {'vect__ngram_range':[(1,1)],
                     'vect__stop_words':[self.stop,None],
                     'vect__tokenizer':[self.tokenizer,
                      self.tokenizer_porter],
                     'vect__use_idf':[False],
                     'vect__norm':[None],
                     'clf__penalty':['l1','l2'],
                     'clf__C':[1.0,10.0,100.0]}]

    lr_tfidf = Pipeline([('vect', tfidf),('clf',LinearSVC())])
    gs_lr_tfidf = GridSearchCV(lr_tfidf,
    param_grid,scoring='accuracy',cv=2,verbose=1,n_jobs=-1)
    gs_lr_tfidf.fit(self.X_train,self.y_train)
    #When I Fit model
    print(accuracy_score(self.y_test,gs_lr_tfidf.predict(self.X_test)))


**    **Process SpawnPoolWorker-16:
    Traceback (most recent call last):
    File "D:\Anaconda3\lib\multiprocessing\process.py", line 249, in _bootstrap
    self.run()
    File "D:\Anaconda3\lib\multiprocessing\process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
    File "D:\Anaconda3\lib\multiprocessing\pool.py", line 108, in worker
    task = get()
    File "D:\Anaconda3\lib\site-packages\sklearn\externals\joblib\pool.py", 
    line 362, in get
    return recv()
    File "D:\Anaconda3\lib\multiprocessing\connection.py", line 251, in recv
    return _ForkingPickler.loads(buf.getbuffer())
    AttributeError: Can't get attribute 'NLP' on <module '__main__' (built-in)>
    [I 10:43:06.693 NotebookApp] Saving file at /NLP class.ipynb****

0 个答案:

没有答案