コード例 #1
0
#Y Scaled
Y_train_scaled = np.log1p(Y_train)
Y_val_scaled = np.log1p(Y_val)

# Y_train_scaled = Y_train
# Y_val_scaled = Y_val

print('Training Models')
model.fit(X_train, Y_train_scaled)
model_val_pred = model.predict(X_val)
model_pred = np.expm1(model.predict(X_test))
score = MAPE_score(Y_val_scaled, model_val_pred, Y_inv_transform_fn=np.expm1)
print('\n V Model Score: {:.4f} ({:.4f})\n'.format(score.mean(), score.std()))

Sub.append(part_sub(test_ID, model_pred))
mapes.append(score)

if not (val and tcv and cv):
    write_file(Sub, 'hdb_whole', date=False)
mapes = np.array(mapes)
cv_mapes = np.array(cv_mapes)
tcv_mapes = np.array(tcv_mapes)
print(tcv_mapes)
print(cv_mapes)
print(mapes)
print('Model TCV MAPE on training dataset: {} ({})'.format(
    tcv_mapes.mean(), tcv_mapes.std()))
print('Model CV MAPE on training dataset: {} ({})'.format(
    cv_mapes.mean(), cv_mapes.std()))
print('MAPE on validation dataset: {} ({})'.format(mapes.mean(), mapes.std()))
コード例 #2
0
ファイル: HDB_town.py プロジェクト: Soufedd/ML2_pr
        # Y_train_scaled = Y_train
        # Y_val_scaled = Y_val

        print('Training Models')
        model.fit(X_train, Y_train_scaled)
        model_val_pred = model.predict(X_val)
        model_preds.append(np.expm1(model.predict(X_test)))
        score = MAPE_score(Y_val_scaled,
                           model_val_pred,
                           Y_inv_transform_fn=np.expm1)
        vs.append(score)
        print('\n V Model {} Score: {:.4f} ({:.4f})\n'.format(
            m + 1, score.mean(), score.std()))

    Sub.append(part_sub(test_ID, model_preds[np.argmin(vs)]))
    mapes.append(np.min(vs))

if not (val and tcv and cv):
    write_file(Sub, 'hdb_town', date=False)
mapes = np.array(mapes)
cv_mapes = np.array(cv_mapes)
tcv_mapes = np.array(tcv_mapes)
print(tcv_mapes)
print(cv_mapes)
print(mapes)
print('Model TCV MAPE on training dataset: {} ({})'.format(
    tcv_mapes.mean(), tcv_mapes.std()))
print('Model CV MAPE on training dataset: {} ({})'.format(
    cv_mapes.mean(), cv_mapes.std()))
print('MAPE on validation dataset: {} ({})'.format(mapes.mean(), mapes.std()))