コード例 #1
0
def logistic_skin():
    print("\nLogistic Regression for Skin Cancer data:\n")
    x_train, x_test, y_train, y_test = get_data_skin()
    logistic = Logistic(x_train, y_train)
    y_pred = logistic.predict(x_train)
    print("\nTraining Classification accuracy: ")
    print(100 - 100 * np.sum(np.abs(y_pred - y_train)) / y_pred.shape[0])
    confusionMatrix(y_train, y_pred)
    y_pred = logistic.predict(x_test)
    print("\nTesting Classification accuracy: ")
    print(100 - 100 * np.sum(np.abs(y_pred - y_test)) / y_pred.shape[0])
    confusionMatrix(y_test, y_pred)
    print("ROC Curve: ")
    plot_roc_curve(y_test, y_pred)
コード例 #2
0
ファイル: logistic_test.py プロジェクト: mieitza/finch
from sklearn.model_selection import train_test_split
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression
from logistic import Logistic


if __name__ == '__main__':
    X, y = make_classification(5000, flip_y=0.5)
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)
    
    clf = Logistic(X.shape[1], 2)
    clf.fit(X_train, y_train, val_data=(X_test, y_test))
    y_pred = clf.predict(X_test)
    final_acc = (y_pred == y_test).mean()
    print("logistic (tensorflow): %.4f" % final_acc)

    clf = LogisticRegression()
    y_pred = clf.fit(X_train, y_train).predict(X_test)
    print("logistic (sklearn):", (y_pred == y_test).mean())