Exemplo n.º 1
0
Arquivo: zlj.py Projeto: boliqq07/BGP
scatter(ytest, y_pre_test, strx='y_true($10^4$T)', stry='y_predict($10^4$T)')
scatter(ytrain, y_pre_train, strx='y_true($10^4$T)', stry='y_predict($10^4$T)')


def scatter2(x, y_true, y_predict, strx='y_true', stry1='y_true(GWh)', stry2='y_predict', stry="y"):
    fig = plt.figure()
    ax = fig.add_subplot(111)
    l1 = ax.scatter(x, y_true, marker='o', s=50, alpha=0.7, c='orange', linewidths=None, edgecolors='blue')
    ax.plot(x, y_true, '-', ms=5, lw=2, alpha=0.7, color='black')
    l2 = ax.scatter(x, y_predict, marker='^', s=50, alpha=0.7, c='green', linewidths=None, edgecolors='blue')
    ax.plot(x, y_predict, '-', ms=5, lw=2, alpha=0.7, color='green')
    # ax.plot([min(x), max(x)], [min(x), max(x)], '--', ms=5, lw=2, alpha=0.7, color='black')
    plt.xlabel(strx)
    plt.legend((l1, l2),
               (stry1, stry2),
               loc='upper left')
    plt.ylabel(stry)
    plt.show()


a = np.arange(2000, 2020)

scatter2(a, y[::-1], y_[::-1], strx='year', stry="y($10^4$T)", stry1='y_true($10^4$T)', stry2='y_predict($10^4$T)')

# #导出
print(x_frame.iloc[:, :].columns.values[ba.support_])
store.to_pkl_sk(ba.estimator_, "model")
all_import["y_predict"] = y_
store.to_csv(all_import, "predict")
Exemplo n.º 2
0
Arquivo: skk.py Projeto: boliqq07/BGP
param_grid3 = [{'n_estimators': [100, 200], 'learning_rate': [0.1, 0.05]}]

# 2 model
ref = RFECV(me2, cv=3)
x_ = ref.fit_transform(x, y)
gd = GridSearchCV(me2, cv=3, param_grid=param_grid2, scoring="r2", n_jobs=1)
gd.fit(x_, y)
score = gd.best_score_

# 1,3 model
# gd = GridSearchCV(me1, cv=3, param_grid=param_grid1, scoring="r2", n_jobs=1)
# gd.fit(x,y)
# es = gd.best_estimator_
# sf = SelectFromModel(es, threshold=None, prefit=False,
#                  norm_order=1, max_features=None)
# sf.fit(x,y)
# feature = sf.get_support()
#
# gd.fit(x[:,feature],y)
# score = gd.best_score_

# 其他模型
# 穷举等...

# 导出
# pd.to_pickle(gd,r'C:\Users\Administrator\Desktop\skk\gd_model')
# pd.read_pickle(r'C:\Users\Administrator\Desktop\skk\gd_model')
store.to_pkl_sk(gd)
store.to_csv(x)
store.to_txt(score)