예제 #1
0
def deserialize_mlp_regressor(model_dict):
    model = MLPRegressor(**model_dict['params'])

    model.coefs_ = model_dict['coefs_']
    model.loss_ = model_dict['loss_']
    model.intercepts_ = model_dict['intercepts_']
    model.n_iter_ = model_dict['n_iter_']
    model.n_layers_ = model_dict['n_layers_']
    model.n_outputs_ = model_dict['n_outputs_']
    model.out_activation_ = model_dict['out_activation_']

    return model
예제 #2
0
        print('mean squared error = {}'.format(mse))
        y_pred = est.predict(X_test)
        r_squared = est.score(X_test, y_test)
        print('r squared = {}'.format(r_squared))
    else:
        mse = mean_squared_error(y_test, est.predict(X_test_std))
        print('mean squared error = {}'.format(mse))
        y_pred = est.predict(X_test_std)
        r_squared = est.score(X_test_std, y_test)
        print('r squared = {}'.format(r_squared))
        #

    test_score = np.zeros((n,), dtype=np.float64)

    for i, y_pred in enumerate(est.staged_predict(X_test)):
        test_score[i] = est.loss_(y_test, y_pred)

    plt.figure(figsize=(12, 6))
    plt.subplot(1, 2, 1)
    plt.title('Deviance')
    plt.plot(np.arange(n) + 1, est.train_score_, 'b-',
         label='Training Set Deviance')
    plt.plot(np.arange(n) + 1, test_score, 'r-',
         label='Test Set Deviance')
    plt.legend(loc='upper right')
    plt.xlabel('Boosting Iterations')
    plt.ylabel('Deviance')
    # #############################################################################
    # Plot feature importance
    feature_importance = est.feature_importances_
    # make importances relative to max importance