本文整理汇总了Python中nltk.classify.scikitlearn.SklearnClassifier.append方法的典型用法代码示例。如果您正苦于以下问题:Python SklearnClassifier.append方法的具体用法?Python SklearnClassifier.append怎么用?Python SklearnClassifier.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nltk.classify.scikitlearn.SklearnClassifier
的用法示例。
在下文中一共展示了SklearnClassifier.append方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_cross_data
# 需要导入模块: from nltk.classify.scikitlearn import SklearnClassifier [as 别名]
# 或者: from nltk.classify.scikitlearn.SklearnClassifier import append [as 别名]
cv_trn, cv_t, all_trn, test_feature, test_label = create_cross_data(train_list, test, 0, 3)
svm_base = []
dt_base = []
nb_base = []
ent_base = []
knn_base = []
svm_result = []
nb_result = []
dt_result = []
ent_result = []
knn_result = []
for i in range(len(cv_trn)):
print "layer_L_cv:"+str(i)
svm_base.append(SklearnClassifier(LinearSVC()).train(cv_trn[i]))
dt_base.append(SklearnClassifier(tree.DecisionTreeClassifier()).train(cv_trn[i]))
ent_base.append(nltk.classify.maxent.MaxentClassifier.train(cv_trn[i], trace=1, max_iter=4))
nb_base.append(nltk.NaiveBayesClassifier.train(cv_trn[i]))
knn_base.append(SklearnClassifier(KNeighborsClassifier(5)).train(cv_trn[i]))
svm_result.append(svm_base[i].classify_many(cv_t[i]))
dt_result.append(dt_base[i].classify_many(cv_t[i]))
ent_result.append(ent_base[i].classify_many(cv_t[i]))
nb_result.append(nb_base[i].classify_many(cv_t[i]))
knn_result.append(knn_base[i].classify_many(cv_t[i]))
#base classifiers
svm_base = SklearnClassifier(LinearSVC()).train(all_trn)
dt_base = SklearnClassifier(tree.DecisionTreeClassifier()).train(all_trn)
ent_base = nltk.classify.maxent.MaxentClassifier.train(all_trn, trace=1, max_iter=4)