_scorer = make_scorer(f1_score,pos_label=0)
grid_searcher = GridSearchCV(clf, parameter_grid, verbose=200, scoring=_scorer)
grid_searcher.fit(X_train, y_train)
clf_best = grid_searcher.best_estimator_
[CV] class_weight=balanced, max_depth=10, n_estimators=100 ...........
[CV] class_weight=balanced, max_depth=10, n_estimators=100, score=0.4419706300331596, total= 16.4s
[Parallel(n_jobs=1)]: Done 12 out of 12 | elapsed: 1.7min remaining: 0.0s
[CV] class_weight=balanced, max_depth=10, n_estimators=150 > – user287629 47 mins ago
y_pred = clf.predict (X_test)
r = np.sum (y_pred == 0) & (y_pred == y_test)
s = np.sum (y_pred == 1) & (y_pred! = y_test)
z = r / s #I need to get a z
答案 0 :(得分:0)
试过这样,不起作用(经验不多):
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5, random_state=42)
def T_scorer(clf, X_test,y_test):
y_pred = clf.predict(X_test)
r = np.sum(y_pred == 0) & (y_pred == y_test)
s = np.sum(y_pred == 1) & (y_pred!= y_test)
z = r / s # I need to get a z
return z
clf = RandomForestClassifier()
grid_searcher = GridSearchCV(clf, parameter_grid, verbose=2, scoring=T_scorer)
grid_searcher.fit(X_test, y_test)
clf_best = grid_searcher.best_estimator_
print('Best params = ', clf_best.get_params())
答案 1 :(得分:0)
试试这个:
java -version