コード例 #1
0
def random_forest(X,y,X_train,y_train,X_test,y_test,params):
    reg = RandomForestClassifier(n_estimators = params['n_estimators'],max_depth = params['max_depth'])
    reg.fit(X_train,y_train)
    y_pre = reg.predict(X_test)
    metrics = show_metrics('Random Forest',y_test,y_pre)
    draw_roc(X,y,X_train,y_train,X_test,y_test,reg)   
    return metrics
コード例 #2
0
def svm(X,y,X_train,y_train,X_test,y_test,params):
    reg = SVC(params)
    reg.fit (X_train,y_train)
    y_pre = reg.predict(X_test)
    metrics = show_metrics('SVM',y_test,y_pre)
    draw_roc(X,y,X_train,y_train,X_test,y_test,reg)
    
    return metrics
コード例 #3
0
def logistic_regression(X,y,X_train,y_train,X_test,y_test,params):
    reg = LogisticRegression(C = params)
    reg.fit (X_train,y_train)
    y_pre = reg.predict(X_test)
    metrics = show_metrics('Logistic Regression',y_test,y_pre)
    draw_roc(X,y,X_train,y_train,X_test,y_test,reg)
    
    return metrics