<jupyter_start><jupyter_text>Applying the learned workplace control models to the demand profiles.Developed by <NAME>, 2021.<jupyter_code>import boto3
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import pickle
import os
clf1 = pickle.load(open('workplace_control_model_1min_avgem_20211119.p', "rb"))
clf2 = pickle.load(open('workplace_control_model_1min_minpeak_20211119.p', "rb"))
folder = '../RunningModel/Outputs/'
filenames = []
filenames += [each for each in os.listdir(folder) if (each.endswith('WECC_20220313.csv'))]
filenames
for file in filenames:
    if 'weekend' in file: # don't apply control on weekends (very few workplace sessions anyway)
        print('Not running: ', file)
    elif 'WPcontrol' in file: # don't do ones where WPcontrol has already been applied
        print('Not running: ', file)
    else:
        test = pd.read_csv(folder+file, index_col=0) # load profile
        normval = np.max(test['Workplace L2'].values) # normalize
        controlled1 = normval * clf1.predict((test['Workplace L2'].values/normval).reshape(1, -1))
        controlled2 = normval * clf2.predict((test['Workplace L2'].values/normval).reshape(1, -1))
        test2 = test.copy(deep=True)
        test2['Workplace L2'] = controlled1.ravel() # apply control 1
        test2.to_csv(folder+file[:-17]+'WPcontrol_avgem_'+file[-17:])
        test3 = test.copy(deep=True)
        test3['Workplace L2'] = controlled2.ravel() # apply control 2
        test3.to_csv(folder+file[:-17]+'WPcontrol_minpeak_'+file[-17:])<jupyter_output>Not running:  LowHome_HighWork_100p_RandomTimers_weekend_WECC_20220313.csv
Not running:  LowHome_HighWork_100p_weekend_WECC_20220313.csv
Not running:  LowHome_LowWork_100p_weekend_WECC_20220313.csv
Not running:  LowHome_LowWork_100p_RandomTimers_weekend_WECC_20220313.csv
Not running:  UniversalHome_100p_NoTimers_weekend_WECC_20220313.csv
Not running:  UniversalHome_100p_RandomTimers_weekend_WECC_20220313.csv
Not running:  LowHome_LowWork_100p_midnighttimer_weekend_WECC_20220313.csv
Not running:  HighHome_100p_midnighttimer_weekend_WECC_20220313.csv
Not running:  HighHome_100p_NoTimers_weekend_WECC_20220313.csv
Not running:  LowHome_LowWork_100p_NoTimers_weekend_WECC_20220313.csv
Not running:  UniversalHome_100p_weekend_WECC_20220313.csv
Not running:  LowHome_HighWork_100p_NoTimers_weekend_WECC_20220313.csv
Not running:  UniversalHome_100p_midnighttimer_weekend_WECC_20220313.csv
Not running:  HighHome_100p_weekend_WECC_20220313.csv
Not running:  LowHome_HighWork_100p_midnighttimer_weeke[...]
{'fraction_non_alphanumeric': 0.09300508010941774, 'fraction_numerical': 0.08675263774912075, 'mean_word_length': 5.937669376693767, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '613676', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 1045, 'n_tokens_neox': 908, 'n_words': 167, 'path': 'EVDemandModel_EVScenarios/Controls/2_ApplyWorkplaceControlModels.ipynb', 'repo_name': 'SiobhanPowell/speech-grid-impact', 'size': '2567'}