Ejemplo n.º 1
0
 def batch():
     print("Tesing the performance of LogisticRegression(batch)...")
     # Train model
     clf = LogisticRegression()
     clf.fit(X=X_train, y=y_train, lr=0.05, epochs=200)
     # Model evaluation
     model_evaluation(clf, X_test, y_test)
 def batch():
     print("Tesing the performance of LogisticRegression(batch)...")
     # Train model
     clf = LogisticRegression()
     clf.fit(data=data_train, label=label_train, learning_rate=0.1, epochs=1000)
     # Model evaluation
     model_evaluation(clf, data_test, label_test)
     print(clf)
 def stochastic():
     print("Tesing the performance of LogisticRegression(stochastic)...")
     # Train model
     clf = LogisticRegression()
     clf.fit(data=data_train, label=label_train, learning_rate=0.01, epochs=100,
             method="stochastic", sample_rate=0.8)
     # Model evaluation
     model_evaluation(clf, data_test, label_test)
     print(clf)
Ejemplo n.º 4
0
 def stochastic():
     print("Tesing the performance of LogisticRegression(stochastic)...")
     # Train model
     clf = LogisticRegression()
     clf.fit(X=X_train, y=y_train, lr=0.01, epochs=100,
             method="stochastic", sample_rate=0.8)
     # Model evaluation
     model_evaluation(clf, X_test, y_test)
     print(clf)
Ejemplo n.º 5
0
def main():
    print("Tesing the performance of RandomForest...")
    # Load data
    X, y = load_breast_cancer()
    # Split data randomly, train set rate 70%
    X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=40)

    # Train model
    rf = RandomForest()
    rf.fit(X_train, y_train, n_samples=300, max_depth=3, n_estimators=20)
    # Model evaluation
    model_evaluation(rf, X_test, y_test)
Ejemplo n.º 6
0
def main():
    print("Tesing the performance of KNN classifier...")
    # Load data
    X, y = load_breast_cancer()
    X = min_max_scale(X)
    # Split data randomly, train set rate 70%
    X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=20)
    # Train model
    clf = KNeighborsClassifier()
    clf.fit(X_train, y_train, k_neighbors=21)
    # Model evaluation
    model_evaluation(clf, X_test, y_test)
Ejemplo n.º 7
0
def main():
    print("Tesing the performance of DecisionTree...")
    # Load data
    X, y = load_breast_cancer()
    # Split data randomly, train set rate 70%
    X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=10)
    # Train model
    clf = DecisionTree()
    clf.fit(X_train, y_train, max_depth=3)
    # Show rules
    clf.rules
    # Model evaluation
    model_evaluation(clf, X_test, y_test)
def main():
    """Tesing the performance of DecisionTree
    """
    print("Tesing the performance of DecisionTree...")
    # Load data
    data, label = load_breast_cancer()
    # Split data randomly, train set rate 70%
    data_train, data_test, label_train, label_test = train_test_split(
        data, label, random_state=10)
    # Train model
    clf = DecisionTree()
    clf.fit(data_train, label_train, max_depth=4)
    # Show rules
    print(clf)
    # Model evaluation
    model_evaluation(clf, data_test, label_test)
Ejemplo n.º 9
0
def main():
    print("Tesing the performance of GBDT classifier...")
    # Load data
    X, y = load_breast_cancer()
    # Split data randomly, train set rate 70%
    X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=20)
    # Train model
    clf = GradientBoostingClassifier()
    clf.fit(X_train,
            y_train,
            n_estimators=2,
            lr=0.8,
            max_depth=3,
            min_samples_split=2)
    # Model evaluation
    model_evaluation(clf, X_test, y_test)
def main():
    """Tesing the performance of RandomForest...
    """
    print("Tesing the performance of RandomForest...")
    # Load data
    data, label = load_breast_cancer()
    # Split data randomly, train set rate 70%
    data_train, data_test, label_train, label_test = train_test_split(
        data, label, random_state=40)

    # Train model
    clf = RandomForest()
    clf.fit(data_train,
            label_train,
            n_estimators=50,
            max_depth=5,
            random_state=10)
    # Model evaluation
    model_evaluation(clf, data_test, label_test)
Ejemplo n.º 11
0
def main():
    """Tesing the performance of GBDT classifier"""

    print("Tesing the performance of GBDT classifier...")
    # Load data
    data, label = load_breast_cancer()
    # Split data randomly, train set rate 70%
    data_train, data_test, label_train, label_test = train_test_split(
        data, label, random_state=20)
    # Train model
    clf = GradientBoostingClassifier()
    clf.fit(data_train,
            label_train,
            n_estimators=2,
            learning_rate=0.8,
            max_depth=3,
            min_samples_split=2)
    # Model evaluation
    model_evaluation(clf, data_test, label_test)