def test_no_boundaries_or_as_of_times(self): with patch( "triage.component.timechop.plotting.plt.show") as show_patch: visualize_chops(self.chopper, show_as_of_times=False, show_boundaries=False) assert show_patch.called
def __call__(self, args): if args.validate_only: try: logger.info(f"Validating experiment [config file: {self.args.config}]") self.experiment.validate() logger.success( f"Experiment ({self.experiment.experiment_hash})'s configuration file is OK!" ) except Exception: logger.exception(f"Validation failed!") logger.info( f"Experiment [config file: {self.args.config}] configuration file is incorrect" ) elif args.show_timechop: experiment_name = os.path.splitext(os.path.basename(self.args.config))[0] project_storage = ProjectStorage(self.args.project_path) timechop_store = project_storage.get_store( ["images"], f"{experiment_name}.png" ) with timechop_store.open("wb") as fd: visualize_chops(self.experiment.chopper, save_target=fd) else: try: logger.info(f"Running Experiment ({self.experiment.experiment_hash})") self.experiment.run() logger.success( f"Experiment ({self.experiment.experiment_hash}) ran through completion" ) except Exception: logger.exception("Something went wrong") logger.info(f"Experiment [config file: {self.args.config}] run failed!")
def __call__(self, args): experiment_config = yaml.load(args.config) if 'temporal_config' not in experiment_config: raise ValueError('Passed configuration must have `temporal_config` key ' 'in order to visualize time chops') chopper = Timechop(**(experiment_config['temporal_config'])) logging.info('Visualizing time chops') visualize_chops(chopper)
def __call__(self, args): experiment_config = yaml.load(args.config) if "temporal_config" not in experiment_config: raise ValueError( "Passed configuration must have `temporal_config` key " "in order to visualize time chops") chopper = Timechop(**(experiment_config["temporal_config"])) logging.info("Visualizing time chops") visualize_chops(chopper)
def __call__(self, args): if args.validate_only: self.experiment.validate() elif args.show_timechop: experiment_name = os.path.splitext( os.path.basename(self.args.config))[0] project_storage = ProjectStorage(self.args.project_path) timechop_store = project_storage.get_store( ["images"], f"{experiment_name}.png") with timechop_store.open('wb') as fd: visualize_chops(self.experiment.chopper, save_target=fd) else: self.experiment.run()
def visualize_timechop(config_file): experiment_config = read_config_file(config_file) temporal_config = experiment_config['temporal_config'] feature_start_time = temporal_config['feature_start_time'] feature_end_time = temporal_config['feature_end_time'] label_start_time = temporal_config['label_start_time'] label_end_time = temporal_config['label_end_time'] model_update_frequency = temporal_config['model_update_frequency'] training_as_of_date_frequencies = temporal_config[ 'training_as_of_date_frequencies'] test_as_of_date_frequencies = temporal_config[ 'test_as_of_date_frequencies'] max_training_histories = temporal_config['max_training_histories'] training_label_timespans = temporal_config['label_timespans'] test_label_timespans = temporal_config['label_timespans'] test_durations = temporal_config['test_durations'] chopper = Timechop( feature_start_time=feature_start_time, feature_end_time=feature_end_time, label_start_time=label_start_time, label_end_time=label_end_time, model_update_frequency=model_update_frequency, training_as_of_date_frequencies=training_as_of_date_frequencies, max_training_histories=max_training_histories, training_label_timespans=training_label_timespans, test_as_of_date_frequencies=test_as_of_date_frequencies, test_durations=test_durations, test_label_timespans=test_label_timespans) dateTimeObj = datetime.now() timestr = dateTimeObj.strftime('%Y%m%d%H%M') user = getpass.getuser() cf = ntpath.basename(config_file)[0:10] data_folder = '/mnt/data/experiment_data/' save_path = os.path.join(data_folder, 'triage', 'elsal', 'timechops', '{}_{}_{}.png'.format(user, timestr, cf)) visualize_chops(chopper=chopper, show_as_of_times=True, show_boundaries=True, save_target=save_path)
# coding: utf-8 from triage.component.timechop.plotting import visualize_chops from triage.component.timechop import Timechop import yaml import matplotlib.pyplot as plt import numpy as np if __name__ == '__main__': with open('simple_config.yaml') as f: experiment_config = yaml.load(f) chopper = Timechop(**(experiment_config["temporal_config"])) visualize_chops(chopper)
def test_default_args(self): with patch( "triage.component.timechop.plotting.plt.show") as show_patch: visualize_chops(self.chopper) assert show_patch.called
) db_engine = create_engine(db_url) # loading config file with open('donors-choose-config.yaml', 'r') as fin: config = yaml.load(fin) # generating temporal config plot chopper = Timechop(**config['temporal_config']) # We aren't interested in seeing the entire feature_start_time represented # in our timechop plot. That would hide the interesting information. So we # set it to equal label_start_time for the plot. chopper.feature_start_time = chopper.label_start_time visualize_chops(chopper, save_target='triage_output/timechop.png') # creating experiment object experiment = MultiCoreExperiment( config=config, db_engine=db_engine, project_path='s3://dsapp-education-migrated/donors-choose', n_processes=32, n_db_processes=4, replace=False) experiment.run()