Exemple #1
0
def run():
    X, y = get_wine_data()
    X1, y1 = get_abalone_data()

    classifier = DecisionTreeClassifier(max_depth=2, min_samples_leaf=3)
    cv = ShuffleSplit(n_splits=100, test_size=0.2, random_state=0)
    title = "Wine - Validation Curve For Decision Tree"
    plot_learning_curve(classifier,
                        title,
                        X,
                        y,
                        ylim=(0.4, 0.6),
                        cv=cv,
                        n_jobs=4).show()

    classifier = DecisionTreeClassifier(max_depth=2, min_samples_leaf=3)
    cv = ShuffleSplit(n_splits=100, test_size=0.2, random_state=0)
    title = "Abalone - Validation Curve For Decision Tree"
    plot_learning_curve(classifier,
                        title,
                        X1,
                        y1,
                        ylim=(0.2, 0.4),
                        cv=cv,
                        n_jobs=4).show()
def run():
    X, y = get_wine_data()
    X1, y1 = get_abalone_data()

    dt = DecisionTreeClassifier(max_depth=2,
                                min_samples_leaf=3,
                                splitter='random')
    classifier = AdaBoostClassifier(base_estimator=dt,
                                    random_state=0,
                                    n_estimators=3)
    cv = ShuffleSplit(n_splits=100, test_size=0.2, random_state=0)
    title = "Wine - Validation Curve For AdaBoostClassifier"
    plot_learning_curve(classifier,
                        title,
                        X,
                        y,
                        ylim=(0.4, 0.6),
                        cv=cv,
                        n_jobs=4).show()

    dt = DecisionTreeClassifier(max_depth=1,
                                min_samples_leaf=3,
                                splitter='random')
    classifier = AdaBoostClassifier(base_estimator=dt,
                                    random_state=0,
                                    n_estimators=15)
    cv = ShuffleSplit(n_splits=100, test_size=0.2, random_state=0)
    title = "Abalone - Validation Curve For AdaBoostClassifier"
    plot_learning_curve(classifier,
                        title,
                        X1,
                        y1,
                        ylim=(0.1, 0.3),
                        cv=cv,
                        n_jobs=4).show()
Exemple #3
0
def run():
    X, y = get_wine_data()
    X1, y1 = get_abalone_data()

    classifier = MLPClassifier(alpha=0.1, hidden_layer_sizes=13, max_iter=5, random_state=0, solver='lbfgs')
    cv = ShuffleSplit(n_splits=100, test_size=0.2, random_state=0)
    title = "Wine - Validation Curve For Neural Network"
    plot_learning_curve(classifier, title, X, y, ylim=(0.2, 0.6), cv=cv, n_jobs=4).show()

    classifier = MLPClassifier(alpha=0.1, hidden_layer_sizes=10, max_iter=9, random_state=0, solver='lbfgs')
    cv = ShuffleSplit(n_splits=100, test_size=0.2, random_state=0)
    title = "Abalone - Validation Curve For Neural Network"
    plot_learning_curve(classifier, title, X1, y1, ylim=(0.1, 0.3), cv=cv, n_jobs=4).show()
Exemple #4
0
def run():
    X, y = get_wine_data()
    X1, y1 = get_abalone_data()

    classifier = SVC(C=10, kernel='linear')
    cv = ShuffleSplit(n_splits=10, test_size=0.2, random_state=0)
    title = "Wine - Validation Curve For Support Vector Machine With Linear Kernel"
    plot_learning_curve(classifier, title, X, y, ylim=(0.0, 1.0), cv=cv, n_jobs=4).show()

    classifier = SVC(C=10, kernel='linear')
    cv = ShuffleSplit(n_splits=10, test_size=0.2, random_state=0)
    title = "Abalone - Validation Curve For Support Vector Machine With Linear Kernel"
    plot_learning_curve(classifier, title, X1, y1, ylim=(0.0, 1.), cv=cv, n_jobs=4).show()

    classifier = SVC(C=10, kernel='rbf', gamma=0.001)
    cv = ShuffleSplit(n_splits=10, test_size=0.2, random_state=0)
    title = "Wine - Validation Curve For Support Vector Machine with RBF Kernel"
    plot_learning_curve(classifier, title, X, y, ylim=(0.0, 1.0), cv=cv, n_jobs=4).show()

    classifier = SVC(C=10, kernel='rbf', gamma=0.001)
    cv = ShuffleSplit(n_splits=10, test_size=0.2, random_state=0)
    title = "Abalone - Validation Curve For Support Vector Machine With Linear Kernel"
    plot_learning_curve(classifier, title, X1, y1, ylim=(0.0, 1.), cv=cv, n_jobs=4).show()
models3 = {'MLPClassifier': MLPClassifier()}

params3 = {
    'MLPClassifier': {
        'solver': ['lbfgs'],
        'max_iter': [1, 3, 5, 7, 9],
        'alpha': 10.0**-np.arange(1, 10),
        'hidden_layer_sizes': np.arange(10, 15),
        'random_state': [0, 1]
    }
}

if __name__ == "__main__":
    X, y = get_wine_data()
    X1, y1 = get_abalone_data()

    # helper1 = EstimatorSelectionHelper(models1, params1)
    # helper1.fit(X, y, scoring='accuracy', n_jobs=4, cv=5)
    # results = (helper1.score_summary(sort_by='max_score'))
    # results.to_csv("out/wine_params_1.csv")

    # helper1 = EstimatorSelectionHelper(models1, params1)
    # helper1.fit(X1, y1, scoring='accuracy', n_jobs=4, cv=5)
    # results = (helper1.score_summary(sort_by='max_score'))
    # results.to_csv("out/abalone_params_1.csv")

    helper1 = EstimatorSelectionHelper(models2, params2)
    helper1.fit(X, y, scoring='accuracy', n_jobs=4, cv=5)
    results = (helper1.score_summary(sort_by='max_score'))
    results.to_csv("out/wine_params_2.csv")