# Implementing Linear_SGD classifierclf = linear_model.SGDClassifier(max_iter=1000)Cs = [0.0001,0.001, 0.01, 0.1, 1, 10]tuned_parameters = [{'alpha': Cs}]model = GridSearchCV(clf, tuned_parameters, scoring = 'accuracy', cv=2)model.fit(x_train, Y_train)如何从下面的代码中找到最重要的功能,因为它显示了错误 feature_count_。这里我的向量化器是 BOW 和分类器是 SGDclassifier 与铰链损失def important_features(vectorizer,classifier,n=20):    class_labels = classifier.classes_    feature_names =vectorizer.get_feature_names()    topn_class1 = sorted(zip(classifier.feature_count_[0],     feature_names),reverse=True)[:n]    topn_class2 = sorted(zip(classifier.feature_count_[1],     feature_names),reverse=True)[:n]    print("Important words in negative reviews")我尝试使用上面的代码,但显示错误为AttributeError                            Traceback (most recent call last)<ipython-input-77-093048fb461e> in <module>()----> 1 important_features(Timesort_X_vec,model)<ipython-input-75-10b9d6ee3f81> in important_features(vectorizer, classifier, n)  2     class_labels = classifier.classes_  3     feature_names =vectorizer.get_feature_names()   ----> 4     topn_class1 = sorted(zip(classifier.feature_count_[0], feature_names),reverse=True)[:n]  5     topn_class2 = sorted(zip(classifier.feature_count_[1], feature_names),reverse=True)[:n]  6     print("Important words in negative reviews") AttributeError: 'GridSearchCV' object has no attribute 'feature_count_'.
                    
                    
                添加回答
举报
0/150
	提交
		取消
	