Ejemplo n.º 1
0
def main(event_sel=None):
    df = read_train()

    #    X_train, y_train = preprocess(df, event_sel=[71, 62, 42])
    #    X_train, y_train = preprocess(df, event_sel=[62, 63, 60])
    X_train, y_train = preprocess(df, event_sel=event_sel)

    from sklearn.linear_model import Perceptron
    clf = Perceptron(max_iter=50, tol=1e-3, random_state=1)

    return benchmark(clf, X_train, y_train)
Ejemplo n.º 2
0
def main(event_sel=None):
    df = read_train()

    #    X_train, y_train = preprocess(df, event_sel=[71, 62, 42])
    #    X_train, y_train = preprocess(df, event_sel=[62, 63, 60])
    X_train, y_train = preprocess(df, event_sel=event_sel)

    from sklearn.neighbors import KNeighborsClassifier
    clf = KNeighborsClassifier(n_neighbors=10)

    return benchmark(clf, X_train, y_train)
Ejemplo n.º 3
0
def main(event_sel=None):
    df = read_train()

#    X_train, y_train = preprocess(df, event_sel=[71, 62, 42])
#    X_train, y_train = preprocess(df, event_sel=[62, 63, 60])
    X_train, y_train = preprocess(df, event_sel=event_sel)

    from sklearn.naive_bayes import BernoulliNB, MultinomialNB
    clf = BernoulliNB(alpha=.01)

    return benchmark(clf, X_train, y_train)
Ejemplo n.º 4
0
def main(event_sel=None):
    df = read_train()

    #    X_train, y_train = preprocess(df, event_sel=[71, 62, 42])
    #    X_train, y_train = preprocess(df, event_sel=[62, 63, 60])
    X_train, y_train = preprocess(df, event_sel=event_sel)

    from sklearn.linear_model import RidgeClassifier
    clf = RidgeClassifier(tol=1e-2, solver="sag", random_state=1)

    return benchmark(clf, X_train, y_train)
Ejemplo n.º 5
0
def main(event_sel=None):
    df = read_train()

    #    X_train, y_train = preprocess(df, event_sel=[71, 62, 42])
    #    X_train, y_train = preprocess(df, event_sel=[62, 63, 60])
    X_train, y_train = preprocess(df, event_sel=event_sel)

    from sklearn.neighbors import NearestCentroid
    clf = NearestCentroid()

    return benchmark(clf, X_train, y_train)
Ejemplo n.º 6
0
def main(event_sel=None):
    df = read_train()

    #    X_train, y_train = preprocess(df, event_sel=event_sel)
    #    X_train, y_train = preprocess(df, event_sel=[31, 78])
    #    X_train, y_train = preprocess(df, event_sel=[71, 62, 42])
    #    X_train, y_train = preprocess(df, event_sel=[71, 62, 42, 55, 11])
    X_train, y_train = preprocess(df, event_sel=[62, 63, 60])

    from lightgbm import LGBMClassifier
    clf = LGBMClassifier(verbose=1, random_state=1, silent=0, n_estimators=400)

    return benchmark(clf, X_train.astype(float), y_train)
Ejemplo n.º 7
0
def main(event_sel=None):
    df = read_train()

    #    X_train, y_train = preprocess(df, event_sel=[71, 62, 42])
    #    X_train, y_train = preprocess(df, event_sel=[62, 63, 60])
    X_train, y_train = preprocess(df, event_sel=event_sel)

    from sklearn.linear_model import SGDClassifier
    clf = SGDClassifier(alpha=.0001,
                        max_iter=50,
                        tol=1e-3,
                        penalty='l2',
                        random_state=1)

    return benchmark(clf, X_train, y_train)
Ejemplo n.º 8
0
def main(event_sel=None):
    df = read_train()

    X_train, y_train = preprocess(df, event_sel=event_sel)
    #    X_train, y_train = preprocess(df, event_sel=[71, 62, 42])
    #    X_train, y_train = preprocess(df, event_sel=[71, 62, 42, 55, 11])
    #    X_train, y_train = preprocess(df, event_sel=[62, 63, 60])

    from sklearn.svm import LinearSVC
    clf = LinearSVC(loss='squared_hinge',
                    penalty='l2',
                    dual=False,
                    tol=1e-3,
                    verbose=0,
                    random_state=1)

    return benchmark(clf, X_train, y_train)
Ejemplo n.º 9
0
def main(event_sel=None):
    df = read_train()

#    X_train, y_train = preprocess(df, event_sel=event_sel)
#    X_train, y_train = preprocess(df, event_sel=[71, 62, 42])
#    X_train, y_train = preprocess(df, event_sel=[71, 62, 42, 55, 11])
    X_train, y_train = preprocess(df, event_sel=[62, 63, 60], ngrams=(2,4))

    print('Extracting best features by a chi-squared test')
    from sklearn.feature_selection import SelectKBest, chi2
    ch2 = SelectKBest(chi2, k=12000)
    X_train = ch2.fit_transform(X_train, y_train)
    print('Extracting done, {}'.format(X_train.shape))

    from sklearn.svm import LinearSVC
    clf = LinearSVC(loss='squared_hinge', penalty='l2', dual=False, tol=1e-3, verbose=0, random_state=1)

    return benchmark(clf, X_train, y_train)