plt.rc('axes', facecolor='#E6E6E6') plt.rc('lines', linewidth=0.8) ml_model_names = ['RandomForest','XGBoost','LogisticRegression'] time = 'second_hour' target_set = ['tornado', 'severe_hail', 'severe_wind'] normalize_method = {'tornado': 'standard', 'severe_hail' : None, 'severe_wind' : None} resample_method = {'tornado': 'under', 'severe_hail' : None, 'severe_wind' : None} imputer_method = 'simple' line_colors = plt_config.colors_for_ml_models_dict line_labels = ml_model_names fig_fname = f'performance_diagram.png' ################# base_plot = PlotStructure() lead_times = np.arange(12)*5 + 60 plt.rc("xtick", labelsize=7) # fontsize of the x-axis tick marks plt.rc("ytick", labelsize=7) # fontsize of the y-axis tick marks vars_to_load = ['AUC_mean', 'AUPDC_NORM_mean', 'CSI_mean', 'BSS_mean'] n_panels = 12 figsize = (10,5) fig, axes = base_plot.create_subplots( n_panels = n_panels, figsize = figsize, n_columns = 3, sharex=True, wspace=0.25,
var_set = ['POD', 'POFD'] mean_vars = [v + '_mean' for v in var_set] lower_bounds = [v + '_lowerbound' for v in var_set] upper_bounds = [v + '_upperbound' for v in var_set] vars_to_load = mean_vars + lower_bounds + upper_bounds + [ 'AUC_mean', 'predictions', 'targets' ] line_colors = plt_config.colors_for_ml_models_dict line_labels = ml_model_names fig_fname = f'roc_diagram.png' ################# base_plot = PlotStructure() n_panels = len(times) * len(target_set) if n_panels <= 3: figsize = (12, 4) else: figsize = (10, 5) fig, axes = base_plot.create_subplots(n_panels=n_panels, figsize=figsize, sharex=True, sharey=True, wspace=0.1, hspace=0.1) ax_iterator = base_plot.axes_to_iterator(n_panels, axes)
from base_plotting import PlotStructure from wofs_ml.io.io import IO, target_vars, uh_baseline_probs, hail_baseline_probs, wnd_baseline_probs from wofs_ml.io.cross_validation_generator import DateBasedCV from wofs_ml.evaluate.metrics import brier_skill_score, bss_reliability from sklearn.metrics import roc_auc_score, average_precision_score import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import (MaxNLocator, FormatStrFormatter, AutoMinorLocator) import os os.environ['KMP_WARNINGS'] = '0' base_plot = PlotStructure() io = IO() time_set = ['first_hour', 'second_hour'] times = ['FIRST HOUR', 'SECOND HOUR'] target_set = ['tornado', 'severe_hail', 'severe_wind'] thresholds = {'tornado': 180, 'severe_hail': 120, 'severe_wind': 80} baseline_thresholds = { 'tornado': np.arange(50, 260, 10), 'severe_hail': np.arange(50, 260, 10), 'severe_wind': np.arange(50, 260, 10) } baseline_per_target = {
from base_plotting import PlotStructure from pymint import InterpretToolkit from wofs_ml.common.load_results import _load_train_data from wofs.util.feature_names import to_readable_names, get_units import matplotlib.pyplot as plt from matplotlib.lines import Line2D target = 'severe_wind' time = 'first_hour' mode = 'multipass' metric = 'norm_aupdc' perm_method = 'backward' drop_opt = 'L1_based_feature_selection_with_manual' n_vars = 12 base_plt = PlotStructure() plt.rc("axes", labelsize=8) def plot_ecdf(df, var, target, ax): """ Plot 1D ECDF """ sns.ecdfplot( ax=ax, data=df, x=var, hue=target, legend=False, )
from wofs_ml.io.io import IO import os from wofs.data.loadMRMSData import MRMSData from wofs.data.loadEnsembleData import EnsembleData from base_plotting import PlotStructure import os import xarray as xr from wofs.processing.ObjectMatching import ObjectMatching, match_to_lsrs from skimage.measure import regionprops import pandas as pd from skimage.color import label2rgb from wofs.data.loadWWAs import loadWWA, is_severe, load_reports base_plot = PlotStructure() mrms = MRMSData() get_time = personal_datetime() io = IO() date = '20180501' time = '2330' fcst_time_idx = 0 valid_date_and_time, initial_date_and_time = get_time.determine_forecast_valid_datetime( date_dir=str(date), time_dir=time, fcst_time_idx=fcst_time_idx) mrms_dbz = mrms.load_single_mrms_time(date_dir=date, valid_datetime=initial_date_and_time,
from wofs.data.loadWWAs import loadWWA import matplotlib.pyplot as matplt import wofs.plotting.plotting_config as plt_config from wofs.plotting.Plot import Plotting import os from wofs.data.loadMRMSData import MRMSData from wofs.data.loadEnsembleData import EnsembleData from base_plotting import PlotStructure from load_predictions import load_ml_predictions, load_baseline, get_timestampes get_time = personal_datetime() mrms = MRMSData() base_plot = PlotStructure() target_cmap = {'tornado': Reds, 'severe_hail': Greens, 'severe_wind': Blues} baseline_names = { 'tornado': 'Mid-level UH' + "\n" + r'> 180 m$^2$ s$^{-2}$', 'severe_hail': 'HAILCAST > 1 in', 'severe_wind': '80-m AGL Wind > 40 kts.' } prob_threshold = { 'tornado': 15., 'severe_hail': 20., 'severe_wind': 20., }
var_set = ['POD', 'SR'] mean_vars = [v+'_mean' for v in var_set] lower_bounds = [v+'_lowerbound' for v in var_set] upper_bounds = [v+'_upperbound' for v in var_set] vars_to_load = mean_vars+lower_bounds+upper_bounds+['AUPDC_NORM_mean', 'targets', 'NCSI_mean', 'FREQ_BIAS_mean'] line_colors = plt_config.colors_for_ml_models_dict line_labels = ml_model_names fig_fname = f'performance_diagram_{drop_opt}.png' add_ci=False ################# base_plot = PlotStructure() n_panels = len(times)*len(target_set) if n_panels <= 3: figsize = (12, 4) else: figsize = (10,5) fig, axes = base_plot.create_subplots( n_panels = n_panels, figsize = figsize, sharex=True, sharey=True, wspace=0.15, hspace=0.15 )
from wofs.util.basic_functions import personal_datetime from wofs.data.loadLSRs import loadLSR from wofs_ml.common.load_results import _load_train_data, _load_test_data, _load_model, just_transforms import matplotlib.pyplot as matplt import wofs.plotting.plotting_config as plt_config from wofs.plotting.Plot import Plotting from wofs_ml.io.io import IO, base_vars_to_drop import os from wofs.data.loadMRMSData import MRMSData from wofs.data.loadEnsembleData import EnsembleData from base_plotting import PlotStructure from copy import deepcopy base_plot = PlotStructure() mrms = MRMSData() get_time = personal_datetime( ) io = IO() model_name = 'RandomForest' target_set = ['tornado'] colorbar_labels = ['Probability of Tornado'] target_cmap = {'tornado' : Reds, 'severe_hail' : Greens, 'severe_wind' : Blues} time_data = 'first_hour' normalize_method = {'tornado': 'standard', 'severe_hail' : None, 'severe_wind' : None} resample_method = {'tornado': 'under', 'severe_hail' : None, 'severe_wind' : None}
vars_to_load = mean_vars + lower_bounds + upper_bounds + [ 'AUPDC_NORM_mean', 'AUC_mean', 'predictions', 'targets', 'NCSI_mean', 'FREQ_BIAS_mean', 'BSS_mean', ] line_colors = plt_config.colors_for_ml_models_dict line_labels = ml_model_names fig_fname = f'all_verification_diagram_{drop_opt}.png' ################# base_plot = PlotStructure() n_panels = 9 figsize = (9, 8) fig, axes = base_plot.create_subplots(n_panels=n_panels, figsize=figsize, sharex=True, sharey=True, wspace=0.15, hspace=0.2) ax_iterator = base_plot.axes_to_iterator(n_panels, axes) fontsize = 8 ax_iterator[0].set_ylabel('Probability of Detection', fontsize=fontsize) ax_iterator[3].set_ylabel('Probability of Detection', fontsize=fontsize) ax_iterator[6].set_ylabel('Conditional Event Frequency', fontsize=fontsize)
######################################## # USER-DEFINED PARAMETERS # ######################################## model_set = ['RandomForest', 'LogisticRegression', 'XGBoost'] time = 'first_hour' pipeline_set = [ ('severe_hail', None, None), ('severe_wind', None, None), ('tornado', 'under', 'standard'), ] imputer_method = 'simple' drop_high_corr_pred = True ####################################### base_plot = PlotStructure() n_panels = len(model_set) * len(pipeline_set) if n_panels < 3: figsize = (5, 4) else: figsize = (8, 5) fig, axes = base_plot.create_subplots(n_panels=n_panels, figsize=figsize, sharex=True, sharey=True, wspace=0.15, hspace=0.15) ax_iterator = base_plot.axes_to_iterator(n_panels, axes)