Description
from timeshap.explainer import global_report
sequence_id_feat = 'id'
time_feat = 'Date'
#pos_dataset = d_test_normalized[d_test_normalized['label'] == 1]
schema = schema = list(trial.columns)
pruning_dict = {'tol': [ 0.025, 0.05],'path': 'prun_all_tf.csv'}
event_dict = {'path': 'event_all_tf.csv', 'rs': 42, 'nsamples': 32000}
feature_dict = {'path': 'feature_all_tf.csv','rs': 42, 'nsamples': 32000, 'feature_names': model_features, 'plot_features': plot_feats}
prun_stats, global_plot = global_report(f, trial, pruning_dict, event_dict, feature_dict, average_event, model_features, schema, sequence_id_feat, time_feat, )
prun_stats
While running the above code, I am getting the following error related to encoding:
UnicodeEncodeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_14916\4246322402.py in
7 event_dict = {'path': 'event_all_tf.csv', 'rs': 42, 'nsamples': 32000}
8 feature_dict = {'path': 'feature_all_tf.csv','rs': 42, 'nsamples': 32000, 'feature_names': model_features, 'plot_features': plot_feats}
----> 9 prun_stats, global_plot = global_report(f, trial, pruning_dict, event_dict, feature_dict, average_event, model_features, schema, sequence_id_feat, time_feat, )
10 prun_stats
c:\programdata\anaconda3\lib\site-packages\timeshap\explainer\global_methods.py in global_report(f, data, pruning_dict, event_dict, feature_dict, baseline, model_features, schema, entity_col, time_col, append_to_files, max_instances, verbose)
294 """
295 prun_indexes, event_data, feat_data =
--> 296 calc_global_explanations(f, data, pruning_dict, event_dict,
297 feature_dict, baseline, model_features,
298 schema, entity_col, time_col, append_to_files,
c:\programdata\anaconda3\lib\site-packages\timeshap\explainer\global_methods.py in calc_global_explanations(f, data, pruning_dict, event_dict, feature_dict, baseline, model_features, schema, entity_col, time_col, append_to_files, max_instances, verbose)
209 else:
210 print("Calculating pruning algorithm")
--> 211 prun_indexes = prune_all(f, data, pruning_dict, baseline,
212 model_features_index, schema, entity_col_index,
213 time_col_index, append_to_files, verbose)
c:\programdata\anaconda3\lib\site-packages\timeshap\explainer\pruning.py in prune_all(f, data, pruning_dict, baseline, model_features, schema, entity_col, time_col, append_to_files, verbose)
414 with open(file_path, 'a', newline='') as file:
415 writer = csv.writer(file, delimiter=',')
--> 416 writer.writerows(local_pruning_data.values)
417
418 prun_data = pd.DataFrame(np.concatenate(ret_prun_data), columns=names)
c:\programdata\anaconda3\lib\encodings\cp1252.py in encode(self, input, final)
17 class IncrementalEncoder(codecs.IncrementalEncoder):
18 def encode(self, input, final=False):
---> 19 return codecs.charmap_encode(input,self.errors,encoding_table)[0]
20
21 class IncrementalDecoder(codecs.IncrementalDecoder):
UnicodeEncodeError: 'charmap' codec can't encode character '\u2264' in position 30: character maps to
Is the issue while writing to the csv or vice versa? I am pretty lost here.