Beispiel #1
0
def AdaBoost(Xcvfit, Ycvfit):
    '''For the AdaBoost classifier, returns
    a vector of scores from cross validation and an instance
    of the classifier fit to the cross validation data'''
    cer.catch_input_error(Xcvfit, Ycvfit)
    clf = AdaBoostClassifier(n_estimators=100)
    scores = cross_validation.cross_val_score(clf, Xcvfit, \
                                              Ycvfit, cv=5, \
                                              scoring='accuracy')
    clf.fit(Xcvfit, Ycvfit)
    return (scores, clf)
Beispiel #2
0
def QuadDiscAnal(Xcvfit, Ycvfit):
    '''For the Quadratic Discriminant Analysis classifier, returns
    a vector of scores from cross validation and an instance
    of the classifier fit to the cross validation data'''
    cer.catch_input_error(Xcvfit, Ycvfit)
    clf = QuadraticDiscriminantAnalysis()
    scores = cross_validation.cross_val_score(clf, Xcvfit, \
                                              Ycvfit, cv=5, \
                                              scoring='accuracy')
    clf.fit(Xcvfit, Ycvfit)
    return (scores, clf)
Beispiel #3
0
def DecisionTree(Xcvfit, Ycvfit):
    '''For the Decision Tree classifier, returns
    a vector of scores from cross validation and an instance
    of the classifier fit to the cross validation data'''
    cer.catch_input_error(Xcvfit, Ycvfit)
    clf = tree.DecisionTreeClassifier()
    scores = cross_validation.cross_val_score(clf, Xcvfit, \
                                              Ycvfit, cv=5, \
                                              scoring='accuracy')
    clf.fit(Xcvfit, Ycvfit)
    return (scores, clf)
Beispiel #4
0
def gaussNB(Xcvfit, Ycvfit):
    '''For the Naive Gaussian Bayes classifier, returns
    a vector of scores from cross validation and an instance
    of the classifier fit to the cross validation data'''
    cer.catch_input_error(Xcvfit, Ycvfit)
    clf = GaussianNB()
    scores = cross_validation.cross_val_score(clf, Xcvfit, \
                                              Ycvfit, cv=5, \
                                              scoring='accuracy')
    clf.fit(Xcvfit, Ycvfit)
    return (scores, clf)
Beispiel #5
0
def NearestNeighbors(Xcvfit, Ycvfit):
    '''For the Nearest Neighbors classifier, returns
    a vector of scores from cross validation and an instance
    of the classifier fit to the cross validation data'''
    cer.catch_input_error(Xcvfit, Ycvfit)
    clf = KNeighborsClassifier(n_neighbors=3, algorithm='auto', \
                               weights = 'uniform')
    scores = cross_validation.cross_val_score(clf, Xcvfit, \
                                              Ycvfit, cv=5, \
                                              scoring='accuracy')
    clf.fit(Xcvfit, Ycvfit)
    return (scores, clf)