本文整理汇总了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==========="
示例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))