Skip to content
Snippets Groups Projects
Commit 5a15139d authored by Millian Poquet's avatar Millian Poquet
Browse files

prediction notebook: shrink hists (py->R)

parent 8404cc04
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ result_filenames = os.listdir(RESULTS_PATH) ...@@ -28,7 +28,7 @@ result_filenames = os.listdir(RESULTS_PATH)
df_all_results = pd.concat([pd.read_csv(RESULTS_PATH+filename, low_memory=False) for filename in result_filenames]) df_all_results = pd.concat([pd.read_csv(RESULTS_PATH+filename, low_memory=False) for filename in result_filenames])
df_all_results = df_all_results.dropna(subset=PRED_COLS) df_all_results = df_all_results.dropna(subset=PRED_COLS)
df_all_results df_all_results.to_csv('/tmp/allresults-mean.csv', index=False)
from sklearn.metrics import mean_absolute_error, mean_squared_error, mean_absolute_percentage_error from sklearn.metrics import mean_absolute_error, mean_squared_error, mean_absolute_percentage_error
...@@ -97,6 +97,7 @@ g.set_ylabel("Prediction Method") ...@@ -97,6 +97,7 @@ g.set_ylabel("Prediction Method")
g.set_xlabel("Mean Absolute Percentage Error (MAPE) ") g.set_xlabel("Mean Absolute Percentage Error (MAPE) ")
plt.tight_layout(pad=0) plt.tight_layout(pad=0)
plt.savefig("./fig3a-pred-mape-mean-power.svg") plt.savefig("./fig3a-pred-mape-mean-power.svg")
plt.savefig("./fig3a-pred-mape-mean-power.pdf")
``` ```
## Processing the max power prediction results ## Processing the max power prediction results
...@@ -122,6 +123,7 @@ result_filenames = os.listdir(RESULTS_PATH) ...@@ -122,6 +123,7 @@ result_filenames = os.listdir(RESULTS_PATH)
df_all_results = pd.concat([pd.read_csv(RESULTS_PATH+filename, low_memory=False) for filename in result_filenames]) df_all_results = pd.concat([pd.read_csv(RESULTS_PATH+filename, low_memory=False) for filename in result_filenames])
df_all_results = df_all_results.dropna(subset=PRED_COLS) df_all_results = df_all_results.dropna(subset=PRED_COLS)
df_all_results.to_csv('/tmp/allresults-max.csv', index=False)
#df_all_results #df_all_results
...@@ -193,73 +195,44 @@ g.set_ylabel("Prediction Method") ...@@ -193,73 +195,44 @@ g.set_ylabel("Prediction Method")
g.set_xlabel("Mean Absolute Percentage Error (MAPE)") g.set_xlabel("Mean Absolute Percentage Error (MAPE)")
plt.tight_layout(pad=0) plt.tight_layout(pad=0)
plt.savefig("./fig3b-pred-mape-max-power.svg") plt.savefig("./fig3b-pred-mape-max-power.svg")
plt.savefig("./fig3b-pred-mape-max-power.pdf")
``` ```
## Getting the actual mean and max power distributions ## Getting the actual mean and max power distributions
### Mean: Figure 2 (a)
```{python} ```{python}
import matplotlib.pyplot as plt # clear all Python memory
import seaborn as sns import sys
sys.modules[__name__].__dict__.clear()
TINY_SIZE = 2 import gc
SMALL_SIZE = 5 gc.collect()
MEDIUM_SIZE = 20
BIGGER_SIZE = 50
FIG_WIDTH = 40
FIG_HEIGHT = 10
plt.clf()
plt.rc('figure', figsize=(8, 6))
plt.rc('font', size=MEDIUM_SIZE) # controls default text sizes
plt.rc('axes', titlesize=MEDIUM_SIZE) # fontsize of the axes title
plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels
plt.rc('xtick', labelsize=MEDIUM_SIZE) # fontsize of the tick labels
plt.rc('ytick', labelsize=MEDIUM_SIZE) # fontsize of the tick labels
plt.rc('legend', fontsize=MEDIUM_SIZE) # legend fontsize
plt.rc('figure', titlesize=MEDIUM_SIZE) # fontsize of the figure title
plt.rc('figure', figsize=(6,4))
g = sns.histplot(x="total_power_mean_watts", data=df_all_results, bins=25, fill=False)
#g.ax.set_yscale('log')
g.set_xlabel("Total Power (watts)")
g.set_ylabel("Number of Jobs")
plt.xticks(ticks=[0,250,500,750,1000,1250,1500], rotation=30)
plt.tight_layout(pad=0)
plt.savefig("./fig2a-distrib-job-power-mean.svg")
``` ```
### Max : Figure 2 (b) ```{R}
```{python} library(tidyverse)
import matplotlib.pyplot as plt
import seaborn as sns data_mean = read_csv('/tmp/allresults-mean.csv')
data_mean %>% ggplot(aes(x=total_power_mean_watts)) +
TINY_SIZE = 2 geom_histogram() +
SMALL_SIZE = 5 scale_y_continuous(labels = scales::label_number()) +
MEDIUM_SIZE = 20 theme_bw(base_size=20) +
BIGGER_SIZE = 50 labs(
FIG_WIDTH = 40 x='Total power (W)',
FIG_HEIGHT = 10 y='Number of jobs'
)
plt.clf() ggsave('./fig2a-distrib-job-power-mean.pdf', width=6, height=3)
ggsave('./fig2a-distrib-job-power-mean.svg', width=6, height=3)
plt.rc('figure', figsize=(8, 6)) rm(data_mean)
plt.rc('font', size=MEDIUM_SIZE) # controls default text sizes
plt.rc('axes', titlesize=MEDIUM_SIZE) # fontsize of the axes title data_max = read_csv('/tmp/allresults-max.csv')
plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels data_max %>% ggplot(aes(x=total_power_max_watts)) +
plt.rc('xtick', labelsize=MEDIUM_SIZE) # fontsize of the tick labels geom_histogram() +
plt.rc('ytick', labelsize=MEDIUM_SIZE) # fontsize of the tick labels scale_y_continuous(labels = scales::label_number()) +
plt.rc('legend', fontsize=MEDIUM_SIZE) # legend fontsize theme_bw(base_size=20) +
plt.rc('figure', titlesize=MEDIUM_SIZE) # fontsize of the figure title labs(
plt.rc('figure', figsize=(6,4)) x='Total power (W)',
y='Number of jobs'
#g = sns.displot(x="total_power_max_watts", data=df_all_results) )
g = sns.histplot(x="total_power_max_watts", data=df_all_results, bins=25, fill=False) ggsave('./fig2b-distrib-job-power-max.pdf', width=6, height=3)
ggsave('./fig2b-distrib-job-power-max.svg', width=6, height=3)
#g.ax.set_yscale('log') rm(data_max)
g.set_xlabel("Total Power (watts)")
g.set_ylabel("Number of Jobs")
plt.xticks(ticks=[0,250,500,750,1000,1250,1500,1750,2000], rotation=30)
plt.tight_layout(pad=0)
plt.savefig("./fig2b-distrib-job-power-max.svg")
``` ```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment