Exemple #1
0
"""
gbc = sklearn_classifier.ClassifierSklearn(base_classifier=classifier,
                                           directory='cern_time_series_classification_gbc/')
"""

gbc.set_params(features=variables)

# training classifier
gbc.fit(signal_train, bck_train)

# <codecell>

# get prediction on data after classification
from cern_utils.predictions_report import PredictionsInfo
report = PredictionsInfo({'GBC': gbc}, signal_test, bck_test)

# <codecell>

#Plot importances of features according to trained model
importance = gbc.get_feature_importance()
importance.sort(['effect'], ascending=False)[['effect']].plot(figsize=(13,3), kind='bar')

# <codecell>

#Plot learning curves to see possible overfitting of trained classifier
from sklearn.metrics import log_loss, roc_auc_score, average_precision_score

def deviance(y_true, y_pred, sample_weight):
    return gbc.base_classifier.loss_(y_true, y_pred)
Exemple #2
0
xgboost = xgboost_classifier.ClassifierXGBoost(directory='xgboost/')
xgboost.set_params(features = variables, params = plst)
#setup additional parameters
xgboost.num_boost_round = 2500
xgboost.watch = False

#trainig classifier
xgboost.fit(signal_train, bck_train)#,\
            #weight_sig=signal_train.get_data(['total_usage']).values,\
            #weight_bck=bck_train.get_data(['total_usage']).values)

# <codecell>

# get prediction on data after classification
from cern_utils.predictions_report import PredictionsInfo
report = PredictionsInfo({'xgboost': xgboost}, signal_test, bck_test)
report_train = PredictionsInfo({'xgboost': xgboost}, signal_train, bck_train)

# <codecell>

#Plot importances of features according to trained model
importance = xgboost.get_feature_importance()
importance.sort(['effect'], ascending=False)[['effect']].plot(figsize=(13,3), kind='bar')

# <codecell>

#Plot learning curves to see possible overfitting of trained classifier
from sklearn.metrics import log_loss, roc_auc_score, average_precision_score

def log_loss(y_true, y_pred):
    return log_loss(y_true, y_pred)