Пример #1
0
def gradient_boosting_cross(X, Y, fold):
    clf = GradientBoostingClassifier(n_estimators=200,
                                     random_state=0,
                                     max_depth=15)
    ypred = cross_val_predict(clf, X, Y, cv=fold)

    print("Mean Squared Error: ", mean_squared_error(y_true=Y, y_pred=ypred))

    util.plot_roc(ypred, Y)
    util.confusion_matrix_report(['Default', 'Good'], ypred, Y)

    return {'Gradient Boosting': ypred}
Пример #2
0
def random_forest_cross(X, Y, fold):
    clf = RandomForestClassifier(n_estimators=200,
                                 n_jobs=30,
                                 random_state=0,
                                 verbose=0)

    ypred = cross_val_predict(clf, X, Y, cv=fold)

    print("Mean Squared Error: ", mean_squared_error(y_true=Y, y_pred=ypred))

    util.plot_roc(ypred, Y)

    util.confusion_matrix_report(['Default', 'Good'], ypred, Y)
    return {'Floresta Aleatória': ypred}
Пример #3
0
 def plot_roc(self, X, y, size_x, size_y):
     """Plot the ROC curve for X_test and y_test.
     """
     plot_roc(self.clf, X, y, size_x, size_y)
Пример #4
0
@author: jason
'''
from util import loaddata, plot_roc, roc
from pipeline import Pipeline
from pyearth.earth import Earth
from sklearn.linear_model.logistic import LogisticRegression
from matplotlib import pyplot
from sklearn.linear_model.stochastic_gradient import SGDClassifier
from sklearn.ensemble.weight_boosting import AdaBoostClassifier
from sklearn.base import ClassifierMixin
class ClassifierPipeline(Pipeline, ClassifierMixin):
    @property
    def classes_(self):
        return self.steps[-1][1].classes_
wtrain, wtest, Xtrain, Xtest, ytrain, ytest = loaddata(nrows=5000)
classifier = ClassifierPipeline([('earth',Earth(max_degree=1)), ('log',LogisticRegression())])
model = classifier#AdaBoostClassifier(base_estimator=classifier)
model = model.fit(Xtrain, ytrain)
ptest = model.predict_proba(Xtest)[:,1]

print model.steps[0][1].trace()
print model.steps[0][1].summary()
pyplot.figure()
plot_roc(*roc(ytest, ptest))
pyplot.show()
# print train[train.columns[-5:-3]]



Пример #5
0
 def plot_roc(self, X, y, size_x, size_y):
     '''Plot the ROC curve for X_test and y_test'''
     plot_roc(self.clf, X, y, size_x, size_y)
Пример #6
0
 def plot_roc(self,X,y,size_x, size_y):
     plot_roc(self.clf,X,y,size_x,size_y)