imputer_method = 'simple'

ale_path = '/work/mflora/ML_DATA/ALE_RESULTS'

start_time = datetime.datetime.now()

for combo in combos:
    model_name, target, resample_method, normalize_method, time = combo
    results_fname = join(
        ale_path,
        f'ale_results_{model_name}_{target}_{time}{drop_opt}{resample_method}.nc'
    )
    myInterpreter = InterpretToolkit()
    myInterpreter.load_results(results_fname)

    results = myInterpreter.calc_ale_variance(model_names=model_name)
    save_fname = join(
        ale_path,
        f'ale_var_results_{model_name.replace("_under", "")}_{resample_method}_{target}_{time}{drop_opt}.nc'
    )

    print(f'Saving {save_fname}...')
    myInterpreter.save_results(fname=save_fname, data=results)

duration = datetime.datetime.now() - start_time
seconds = duration.total_seconds()
hours = seconds // 3600
minutes = (seconds % 3600) // 60
seconds = seconds % 60

message = f"""
Exemple #2
0
for combo in combos:
    model_name, target, resample_method, normalize_method, time = combo
    results_fname = join(ale_path, f'ale_2d_results_{model_name}_{target}_{time}{drop_opt}{resample_method}.nc')
    myInterpreter = InterpretToolkit()
    results_2d = myInterpreter.load_results(results_fname)

    #if resample_method == 'under':
    #    model_name +='_under'

    # Load the permutation important results from the saved pickle file
    with open(f'IMPORTANT_FEATURES_ALL_MODELS_{target}_{time}.pkl', 'rb') as pkl_file:
        important_vars = pickle.load(pkl_file)

    features = list(itertools.combinations(important_vars, r=2))

    results = myInterpreter.calc_ale_variance(ale_data=results_2d, features=features, interaction=True) 
    results_fname = join(ale_path, f'ale_interaction_results_{model_name.replace("_under", "")}_{resample_method}_{target}_{time}{drop_opt}.nc')

    print(f'Saving {results_fname}...')
    myInterpreter.save_results(fname=results_fname, data=results)

    results_2d.close()
    del results_2d 

duration =  datetime.datetime.now() - start_time
seconds = duration.total_seconds()
hours = seconds // 3600
minutes = (seconds % 3600) // 60
seconds = seconds % 60
    
message = f"""