Esempio n. 1
0
X_train, y_train = train[stg.PLAYER_FEATURES], train[stg.PLAYER_TARGET]
X_test, y_test = test[stg.PLAYER_FEATURES], test[stg.PLAYER_TARGET]

logging.info('Impute missing values with median ..')
X_test.fillna(X_train.median(), inplace=True)
X_train.fillna(X_train.median(), inplace=True)
logging.info('.. Done')

logging.info('Pipeline')
player_pipeline = make_pipeline(
    make_union(
        FastICA(tol=0.85),
        FunctionTransformer(copy)
    ),
    ExtraTreesClassifier(n_estimators=75, max_depth=18, bootstrap=False,
                         criterion="gini", max_features=0.1,
                         min_samples_leaf=1, min_samples_split=2)
)

player_pipeline.fit(X_train, y_train)
logging.info('.. Done')

logging.info('Performance evaluation ..')
pred = player_pipeline.predict(X_test)
pa = PerformanceAnalyzer(y_true=y_test, y_pred=pred)
accuracy = pa.compute_classification_accuracy()
logging.info('Classification accuracy: {}'.format(accuracy))
logging.info('.. Done')

logging.info('End of script {}'.format(basename(__file__)))
Esempio n. 2
0
        ycoords_model.load_model(save_modelname=stg.Y_PROJ_MODEL_NAME)
        logging.info('.. Done')

    """
    x_true = train[stg.X_PROJ_TARGET]
    x_pred = train['x_along_team1_axis_lag1']
    y_true = train[stg.Y_PROJ_TARGET]
    y_pred = train['y_along_team1_axis_lag1']

    true = [(x, y) for (x, y) in zip(x_true, y_true)]
    pred = [(x, y) for (x, y) in zip(x_pred, y_pred)]

    pa = PerformanceAnalyzer(y_true=true, y_pred=pred)
    accuracy = pa.compute_accuracy_l2_error()
    print('L2 accuracy: {}'.format(accuracy))
    """

    logging.info('Performance evaluation ..')
    xcoords_pred = xcoords_model.predict(test_data=X_test_xcoords)
    ycoords_pred = ycoords_model.predict(test_data=X_test_ycoords)

    pred = [(x, y) for (x, y) in zip(xcoords_pred, ycoords_pred)]
    true = [(x, y) for (x, y) in zip(y_test_xcoords, y_test_ycoords)]

    pa = PerformanceAnalyzer(y_true=true, y_pred=pred)
    accuracy = pa.compute_accuracy_l2_error()
    logging.info('L2 accuracy: {}'.format(accuracy))
    logging.info('.. Done')

logging.info('End of script {}'.format(basename(__file__)))