コード例 #1
0
clf.fit(dataset_train_x, dataset_train_y)
print("Linear Regression (SGD) Training Score: {}".format(
    round(clf.score(dataset_train_x, dataset_train_y), 2)))
print("Linear Regression (SGD) Testing Score: {}".format(
    round(clf.score(dataset_test_x, dataset_test_y), 2)))

# Bagging with decesion stumps
clf = bagging(n_estimators=200, oob_score=True)
clf.fit(dataset_train_x, dataset_train_y)
print("Bagging Training Score: {}".format(
    round(clf.score(dataset_train_x, dataset_train_y), 2)))
print("Bagging Testing Score: {}".format(
    round(clf.score(dataset_test_x, dataset_test_y), 2)))

# Adaboost
clf = adaboost(n_estimators=50, learning_rate=.3)
clf.fit(dataset_train_x, dataset_train_y)
print("Adaboost Training Score: {}".format(
    round(clf.score(dataset_train_x, dataset_train_y), 2)))
print("Adaboost Testing Score: {}".format(
    round(clf.score(dataset_test_x, dataset_test_y), 2)))

# SVM
clf = SVC(C=0.75, gamma=2.0)
clf.fit(dataset_train_x, dataset_train_y)
print("SVM Training Score: {}".format(
    round(clf.score(dataset_train_x, dataset_train_y), 2)))
print("SVM Testing Score: {}".format(
    round(clf.score(dataset_test_x, dataset_test_y), 2)))

# Multi-level Perceptron Neural Network
コード例 #2
0
print("Hey")

#configuration4=config(query_size, RandomForest, quire, TfidfVectorizer,50, [], [5,(1,1)] )
#model4=ALmodel(configuration4,X_train,y_train,X_test,y_test,selection)
#model4.run()

ps = PlotStyles()
vectorizer = tfidfvec(max_features=5000, min_df=5, ngram_range=(1, 1))
vectorizer.fit(X_train)
X_full_Vect = vectorizer.transform(X_train)
from sklearn.multiclass import OneVsRestClassifier
from sklearn.ensemble import RandomForestClassifier as randoforest
from sklearn.ensemble import AdaBoostClassifier as adaboost
from sklearn.svm import LinearSVC

model_full = OneVsRestClassifier(adaboost())
model_full.fit(X_full_Vect, y_train)
prediction = model_full.predict(vectorizer.transform(X_test))
accuracy_whole = accuracy_score(y_test, prediction)

fig, ax = setup()

training_size = [m * query_size for m in range(len(model.accuracy_test))]
accuracy_whole = [accuracy_whole for m in range(len(model.accuracy_test))]

print(model.accuracy_test)
print(model_r.accuracy_test)
print(model2.accuracy_test)
print(model5.accuracy_test)
print(accuracy_whole)
ax.plot(training_size,
コード例 #3
0
 def __init__(self,params):
     self.name="Adaboost"
     self.__model=adaboost()
     self.params=params
     self.case='binary'
コード例 #4
0
 def __get_ensemble__(self):
     return adaboost(base_estimator=self.__get_base_estimator__(),
                     n_estimators=30,
                     learning_rate=1e-2)
コード例 #5
0
 def __init__(self,params):
     self.name="OneVsRestClassifier Adaboost"
     self.__model=OneVsRestClassifier(adaboost())
     self.params=params
     self.case='multiclass'