Paper reproduction
Thread
- supernnova.paper.superNNova_thread.SuperNNova_stats_and_plots(settings)[source]
Reproduce stats and plots used for SuperNNova paper. BEWARE: Selection is hardcoded
- Parameters:
settings (ExperimentSettings) – custom class to hold hyperparameters
- supernnova.paper.superNNova_thread.SuperNNova_stats_and_plots_thread(df, settings, plots=True, debug=False)[source]
Stats quoted in paper which are not in the latex tables and plots
- Parameters:
df (pandas.DataFrame) – summary statistics df
settings (ExperimentSettings) – custom class to hold hyperparameters
plots (Boolean optional) – make pltos or only printout stats
debug (Boolean optional) – only print tasks
- Returns:
stats as organized in paper figures (png) : figures for paper at settings.dump_dir/figures/ lightcurves (png): lightcurves used on paper at settings.dump_dir/lightcurves/modelname.*png
- Return type:
printout
Metrics
- supernnova.paper.superNNova_metrics.select_df(df, sel_criteria, data=None)[source]
Select a subsample of a pandas Dataframe Valid only for one to two selection criteria
- Parameters:
df (Pandas.Dataframe) –
sel_criteria (list) – selection criteria
data (optional) – if source_data must be override
- supernnova.paper.superNNova_metrics.get_delta_metrics(df_stats, settings)[source]
Difference between models in SuperNNova paper.
BEWARE: selection hard coded
- Parameters:
df (pandas.DataFrame) – dataframe containing summary stats
settings (ExperimentSettings) – custom class to hold hyperparameters
- Returns:
dataframe containing delta metrics
- Return type:
df (pandas.DataFrame)
- supernnova.paper.superNNova_metrics.create_accuracy_latex_tables(df, settings)[source]
Latex accuracy tables for paper.
BEWARE: Selection is hardcoded
- Parameters:
df (pandas.DataFrame) – summary statistics df
settings (ExperimentSettings) – custom class to hold hyperparameters
Plots
- supernnova.paper.superNNova_plots.create_sigma_df(df_grouped, class_=0)[source]
From grouped prediction df create a df with sigma values
- supernnova.paper.superNNova_plots.plot_acc_vs_nsn(df, settings)[source]
Plot accuracy vs number of SNe used for training
- Parameters:
df (DataFrame) – prediction dataframe
settings (ExperimentSettings) – custom class to hold hyperparameters
- Returns:
figure (png)
- supernnova.paper.superNNova_plots.plot_calibration(settings)[source]
Plot reliability diagram
- Parameters:
settings (ExperimentSettings) – custom class to hold hyperparameters
- Returns:
figure (png)
- supernnova.paper.superNNova_plots.plot_confusion_matrix(settings, cm, classes, normalize=False, cmap=<matplotlib.colors.LinearSegmentedColormap object>, nameout=None)[source]
Plot confusion matrix Based on sklearn tutorial
- Parameters:
settings (ExperimentSettings) – custom class to hold hyperparameters
cm (np.array) – confusion matrix
classes (list) – name of classes in cm
normalize (optional) – Normalization can be applied by setting normalize=True
cmap (colormap) –
nameout (optional) – out name for figure
- Returns:
figure (png)
- supernnova.paper.superNNova_plots.multiplot_violin_paper(df, fname, settings)[source]
Plot data properties as violin plots.
Far from optimized code: seaborn does not make this easy so added a lot of formatting using raw matplotlib commands
- Parameters:
df (DataFrame) – prediction dataframe
fname (filename) –
settings (ExperimentSettings) – custom class to hold hyperparameters
- Returns:
figure (png)
- supernnova.paper.superNNova_plots.binned_2d(bin_centers, y_dic, xname, yname, label_list, color_sequence, MARKER_LIST, nameout, extra_line=None)[source]
Plot scatter plot
- Parameters:
bin_centers (np.array) – x centers
y_dic (dict) – y values
xname (str) – xlabel
yname (str) – ylabel
label_list (list(str)) – for legend
color_sequence (list(str)) – color code
MARKER_LIST (list(str)) – marker code
nameout (str) – out name of figure (.png)
extra_line (optional) – extra line on 0 and 100 (y)
- Returns:
figure (png)
- supernnova.paper.superNNova_plots.plot_acc_matrix(acc_dic, n_meas_dic, settings, nameout)[source]
Plot accuracy matrix
- Parameters:
acc_dic (dict) – with np.arrays of accuracy
n_meas_dic (dict) – with n measurements required for this accuracy
settings (ExperimentSettings) – custom class to hold hyperparameters
nameout (str) – outname for plot
- Returns:
figure (png)
- supernnova.paper.superNNova_plots.plot_HDres_histos_vs_z(df, nameout, threshold_var='class0', threshold_list=[0.5, 0.7, 0.9], threshold_sign='>')[source]
Plot Hubble diagram residuals and histograms selects class sample and performas HD
- Parameters:
df (DataFrame) – predictions
nameout (str) – outname figure
threshold_var (str) – which class used for sample selection
threshold_list (list) – list of probability threshold for selecting sample
threshold_sign (str) – sign of the probability threshold (e.g. “>” )
- Returns:
figure (png)
- supernnova.paper.superNNova_plots.seaborn_formatting_mag(df, settings)[source]
Seaborn friendly formatting
Basic formatting and eliminating outliers (to avoid rejection by seaborn of pd.DataFrame)
- Parameters:
df (DataFrame) – predictions
settings (ExperimentSettings) – custom class to hold hyperparameters
- Returns:
reformatted
- Return type:
df (DataFrame)
- supernnova.paper.superNNova_plots.make_measurements_df(df, settings, group_bayesian=False)[source]
Obtain measurements :param df: predictions :type df: DataFrame :param settings: custom class to hold hyperparameters :type settings: ExperimentSettings :param group_bayesian: if BRNNs ar eused need to group predictions :type group_bayesian: Boolean
- Returns:
with measurements and necessary keys to compute accuracy
- Return type:
df (DataFrame)
- supernnova.paper.superNNova_plots.distance_modulus(df)[source]
Add distance modulus :param df: with SALT2 fitted features :type df: DataFrame
- Returns:
with distance modulus computed
- Return type:
df (DataFrame)
- supernnova.paper.superNNova_plots.sel_eff(merged, threshold, settings)[source]
Efficiency curve for different probabilities
- Parameters:
df (DataFrame) – with SALT2 fitted features
- Returns:
mean_bins (np.array) efficience (np.array)
- supernnova.paper.superNNova_plots.datasets_plots(df, settings)[source]
Dataset violin plots peak magnitudes and redshift distributions of representative and non-representative datasets
- Parameters:
df (DataFrame) – predictions
settings (ExperimentSettings) – custom class to hold hyperparameters
- supernnova.paper.superNNova_plots.performance_plots(settings)[source]
- Performance: accuracy vs. size training set
Uses only Saltfit data and Baseline and Random Forest models
- Parameters:
settings (ExperimentSettings) – custom class to hold hyperparameters
- supernnova.paper.superNNova_plots.purity_vs_z(df, model_name, settings)[source]
Purity and contamination redshift evolution
- Parameters:
df (DataFrame) –
modelname (str) – name of model to be used
settings (ExperimentSettings) – custom class to hold hyperparameters
- supernnova.paper.superNNova_plots.cadence_acc_matrix(df, model_name, settings)[source]
Matrix with accuracy w.r. number of measurements in a band
Correlation between accuracy and a certain number of observations required per filter
- Parameters:
df (DataFrame) –
modelname (str) – name of model to be used
settings (ExperimentSettings) – custom class to hold hyperparameters
- supernnova.paper.superNNova_plots.hubble_residuals(df, model_name, fits, settings)[source]
Hubble residuals for classified supernovae as type Ia
Uses SALT2 fits to compute the distance modulus, therefore list is not complete if fit failed.
- Parameters:
df (DataFrame) –
modelname (str) – name of model to be used
fits (DataFrame) – information from SALT2 fit
settings (ExperimentSettings) – custom class to hold hyperparameters
- supernnova.paper.superNNova_plots.cnf_matrix(df, model_name, settings)[source]
Get confusion matrix from predictions
- Parameters:
df (DataFrame) – predictions for a given model
modelname (str) – name of model to be used
settings (ExperimentSettings) – custom class to hold hyperparameters
- supernnova.paper.superNNova_plots.plot_speed_benchmark(dump_dir)[source]
Plot RNN inference speed benchmarks
N.B. You should have run the speed benchmarks with
Plot speed based on device
Plot speed based on choice of model (BBB, Variational or Baseline)
- Parameters:
dump_dir (str) – Root folder where results are stored
- supernnova.paper.superNNova_plots.create_OOD_classification_plots(df, list_models, settings)[source]
OOD classification for a model (ppercentages of predictions by class and uncertainties)
- Parameters:
df (pandas.DataFrame) – summary statistics df
list – list with models to use
settings (ExperimentSettings) – custom class to hold hyperparameters
- supernnova.paper.superNNova_plots.science_plots(settings, onlycnf=False)[source]
Plots for SuperNNova paper
Saved in settings.figures_dir. Need to provide prediction files and linked settings
- Parameters:
settings (ExperimentSettings) – custom class to hold hyperparameters