当前位置: 首页>>代码示例>>Python>>正文


Python RandomForestClassifier.verbose方法代码示例

本文整理汇总了Python中sklearn.ensemble.RandomForestClassifier.verbose方法的典型用法代码示例。如果您正苦于以下问题:Python RandomForestClassifier.verbose方法的具体用法?Python RandomForestClassifier.verbose怎么用?Python RandomForestClassifier.verbose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sklearn.ensemble.RandomForestClassifier的用法示例。


在下文中一共展示了RandomForestClassifier.verbose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build_model

# 需要导入模块: from sklearn.ensemble import RandomForestClassifier [as 别名]
# 或者: from sklearn.ensemble.RandomForestClassifier import verbose [as 别名]
	def build_model(self, move_number):
		"""given a move_number, generate a model from npboard picked files and pickle model"""
		X_train, y_train, X_test, y_test = self.load_data(move_number)
		model = RandomForestClassifier(verbose = 2, n_estimators = 100, n_jobs = 3)
		#model = GradientBoostingClassifier(learning_rate = 0.1, n_estimators = 100, max_depth=6, verbose = 2)
		#nnet_layers = [Layer("Rectifier", units=361), Layer('Softmax')]
		#model = Classifier(layers=nnet_layers, learning_rate=0.01, learning_rule='momentum', learning_momentum=.9, batch_size=25, valid_size=0.1, n_stable=10, n_iter=10, verbose=True)
		print "beginning training on", len(X_train), "items"
		model = model.fit(X_train, y_train)
		model.verbose = 0
		pickle.dump( model, open( "model"+str(move_number)+".pkl", "wb" ))
		#self.models[move_number] = RFC_model
		del X_train, y_train, X_test, y_test
		print "==========="+str(move_number)+" COMPLETE==========="
开发者ID:birdmw,项目名称:Go-AI,代码行数:16,代码来源:model_manager.py

示例2: range

# 需要导入模块: from sklearn.ensemble import RandomForestClassifier [as 别名]
# 或者: from sklearn.ensemble.RandomForestClassifier import verbose [as 别名]
parameters = {
    # 'n_estimators': range(10, 10000, 1000)
    'n_estimators': [4096]
}


# classifier = RandomForestClassifier(n_estimators=2048, n_jobs=-1, verbose=1)
classifier = RandomForestClassifier(n_jobs=-1, verbose=1)
# classifier.fit(train, target)

clf = grid_search.GridSearchCV(classifier, parameters, verbose=2)
clf.fit(train, target)

clf.verbose = 0
classifier.verbose = 0

print("best estimator %s " % clf.best_estimator_)
print("best params: %s " % clf.best_params_)
print("best score %s " % clf.best_score_)

n_samples = np.min([len(train), len(test)])
cv = cross_validation.ShuffleSplit(n_samples, n_iter=5, test_size=0.3, random_state=15)

scores = cross_validation.cross_val_score(clf.best_estimator_, train, target, cv=cv)
# scores = cross_validation.cross_val_score(clf, train, target, cv=clf.best_estimator_)
print("Accuracy train: %0.4f (+/- %0.4f)" % (scores.mean(), scores.std() * 2))

scores = cross_validation.cross_val_score(clf.best_estimator_, test, expected, cv=cv)
# scores = cross_validation.cross_val_score(clf, test, expected, cv=clf.best_estimator_)
print("Accuracy test : %0.4f (+/- %0.4f)" % (scores.mean(), scores.std() * 2))
开发者ID:PestBusters,项目名称:WheatClassifier,代码行数:32,代码来源:classifier_color.py


注:本文中的sklearn.ensemble.RandomForestClassifier.verbose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。