~vonfry/cpipc-2020

d488fce6c5e1ed3370961770d2ba17d3093751ea — Vonfry 2 years ago 4ab75a8
rename some variable
1 files changed, 11 insertions(+), 10 deletions(-)

M 3optimization.py
M 3optimization.py => 3optimization.py +11 -10
@@ 113,25 113,26 @@ df_original_best_x_norm = (df_original_best_x - df_original_best_x.mean()) / df_

df_norm = (df - df.mean()) / df.std()

df_133_ron_loss_norm = df_norm.iloc[132]['RON损失']
sample_index = 132
df_sample_ron_loss_norm = df_norm.iloc[sample_index]['RON损失']
df_std_s = df.std()['_硫含量']
df_mean_s = df.mean()['_硫含量']
df_std_ron_loss = df.std()['RON损失']
df_mean_ron_loss = df.mean()['RON损失']
pred_opted_133 = model.pred(np.array([df_original_best_x_norm[feature].iloc[132]]))[0]
optimization_133_analysis = pd.DataFrame({
    'optimized_s': [pred_opted_133[1] * df_std_s + df_mean_s],
    'optimized_ron_loss': [pred_opted_133[0] * df_std_ron_loss + df_mean_ron_loss],
    'ron_loss_rate': [(pred_opted_133[0]- df_133_ron_loss_norm) / df_133_ron_loss_norm]
pred_opted_sample = model.pred(np.array([df_original_best_x_norm[feature].iloc[sample]]))[0]
optimization_sample_analysis = pd.DataFrame({
    'optimized_s': [pred_opted_sample[1] * df_std_s + df_mean_s],
    'optimized_ron_loss': [pred_opted_sample[0] * df_std_ron_loss + df_mean_ron_loss],
    'ron_loss_rate': [(pred_opted_sample[0]- df_sample_ron_loss_norm) / df_sample_ron_loss_norm]
})
optimization_133_analysis.to_csv('./data/optimization_133_analysis.csv')
optimization_sample_analysis.to_csv('./data/optimization_sample_analysis.csv')

optimization_and_original_133 = pd.DataFrame(
    np.array([opt, df[unmodified_feature + modified_feature].iloc[132]]),
optimization_and_original_sample = pd.DataFrame(
    np.array([opt, df[unmodified_feature + modified_feature].iloc[sample]]),
    columns = unmodified_feature + modified_feature,
    index = ['optimized', 'original']
)
optimization_and_original_133.to_csv('./data/optimization-133-both.csv')
optimization_and_original_sample.to_csv('./data/optimization-sample-both.csv')

import matplotlib.pyplot as plt