mlclouds.autoxval.TrainTest

class TrainTest(data_files, config={'epochs_a': 100, 'epochs_b': 90, 'features': ['solar_zenith_angle', 'cloud_type', 'refl_0_65um_nom', 'refl_0_65um_nom_stddev_3x3', 'refl_3_75um_nom', 'temp_3_75um_nom', 'temp_11_0um_nom', 'temp_11_0um_nom_stddev_3x3', 'cloud_probability', 'cloud_fraction', 'air_temperature', 'dew_point', 'relative_humidity', 'total_precipitable_water', 'surface_albedo'], 'hidden_layers': [{'activation': 'relu', 'dropout': 0.1, 'units': 256}, {'activation': 'relu', 'dropout': 0.1, 'units': 256}, {'activation': 'relu', 'dropout': 0.1, 'units': 256}, {'activation': 'relu', 'dropout': 0.1, 'units': 256}, {'activation': 'relu', 'dropout': 0.1, 'units': 256}], 'learning_rate': 0.0005, 'loss_weights_a': [1, 0], 'loss_weights_b': [0.5, 0.5], 'metric': 'relative_mae', 'n_batch': 64, 'one_hot_categories': {'flag': ['clear', 'ice_cloud', 'water_cloud', 'bad_cloud']}, 'p_fun': 'p_fun_all_sky', 'p_kwargs': {'loss_terms': ['mae_ghi']}, 'phygnn_seed': 0, 'surfrad_window_minutes': 15, 'training_prep_kwargs': {'add_cloud_flag': True, 'filter_clear': False, 'filter_daylight': True, 'filter_sky_class': False, 'nan_option': 'interp', 'sza_lim': 89}, 'y_labels': ['cld_opd_dcomp', 'cld_reff_dcomp']}, test_fraction=0.2, stats_file=None, model_file=None, history_file=None)[source]

Bases: object

Train and test a model using a single dataset. Reserve a percentage of the data for testing that is not used for training.

Parameters:
  • data_files (list of str | str) – File or list of files to use for training and testing. Filenames must include the four-digit year and satellite indicator (east|west).

  • config (dict) – Phygnn configuration dict

  • test_fraction (float) – Fraction of full data set to reserve for testing. Should be between 0 to 1. The test set is randomly selected and dropped from the training set.

  • stats_file (str | None) – If str, save stats to stats_file

  • model_file (str | None) – If str, save model to model_file (pkl and json)

  • history_file (str | None) – If str, save model training history to history_file.

Methods

save_history(fp)

Save model training history to disk

save_model(fp)

Save model to disk

save_model(fp)[source]

Save model to disk

Parameters:

fp (str) – File name and path for model file (pkl and json)

save_history(fp)[source]

Save model training history to disk

Parameters:

fp (str) – File name and path for csv