pyVHR
pyVHR copied to clipboard
run_on_dataset Error (method)
Helo i am trying to run this code but i a getting an keyerror that i couldnt trace. Hope you can help..Thanks
import os import sys import time
from pyVHR.analysis.multi_method_suite import MultiMethodSuite, TestResult from pyVHR.analysis.pipeline import Pipeline from pyVHR.analysis.stats import StatAnalysis import matplotlib.pyplot as plt import plotly.graph_objects as go
def main():
t1 = time.time()
# Evaluation
evaluation = Pipeline()
results = evaluation.run_on_dataset(configFilename=r"D:\Files\pyVHR-master\pyVHR-master\pyVHR\analysis\ubfc1_evaluation.cfg", verb=True)
results.saveResults(r"D:\Files\pyVHR-master\pyVHR-master\results\ufc1_quick_evaluation.h5")
print(" #### Time consumed in the evaluation: {} seconds...".format(time.time() - t1))
# Visulization of results
st = StatAnalysis(filepath=r"D:\Files\pyVHR-master\pyVHR-master\results\ufc1_quick_evaluation.h5")
y_df, fig_stats = st.run_stats()
fig = st.displayBoxPlot(metric='MAE')
fig.show()
fig = st.displayBoxPlot(metric='RMSE')
fig.show()
fig = st.displayBoxPlot(metric='SNR')
fig.show()
if name == 'main': main()
** Run the test with the following config: dataset: UBFC1 methods: ['CUPY_CHROM_FILTER', 'CUPY_POS_FILTER', 'CPU_OMIT']
Time consumed in the evaluation: 0.060054779052734375 seconds...
KeyError Traceback (most recent call last) File ~\anaconda3\envs\pyvhr\lib\site-packages\pandas\core\indexes\base.py:3621, in Index.get_loc(self, key, method, tolerance) 3620 try: -> 3621 return self._engine.get_loc(casted_key) 3622 except KeyError as err:
File ~\anaconda3\envs\pyvhr\lib\site-packages\pandas_libs\index.pyx:136, in pandas._libs.index.IndexEngine.get_loc()
File ~\anaconda3\envs\pyvhr\lib\site-packages\pandas_libs\index.pyx:163, in pandas._libs.index.IndexEngine.get_loc()
File pandas_libs\hashtable_class_helper.pxi:5198, in pandas._libs.hashtable.PyObjectHashTable.get_item()
File pandas_libs\hashtable_class_helper.pxi:5206, in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'method'
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last) Input In [1], in <cell line: 33>() 30 fig.show() 33 if name == 'main': ---> 34 main()
Input In [1], in main() 20 print(" #### Time consumed in the evaluation: {} seconds...".format(time.time() - t1)) 22 # Visulization of results ---> 23 st = StatAnalysis(filepath=r"D:\Files\pyVHR-master\pyVHR-master\results\ufc1_quick_evaluation.h5") 24 y_df, fig_stats = st.run_stats() 25 fig = st.displayBoxPlot(metric='MAE')
File ~\anaconda3\envs\pyvhr\lib\site-packages\pyVHR\analysis\stats.py:48, in StatAnalysis.init(self, filepath, join_data, remove_ouliers) 45 self.remove_ouliers = remove_ouliers 47 # -- get data ---> 48 self.__getMethods() 49 self.metricSort = {'MAE':'min','RMSE':'min','PCC':'max', 'CCC': 'max'} 50 self.scale = {'MAE':'log','RMSE':'log','PCC':'linear', 'CCC':'linear'}
File ~\anaconda3\envs\pyvhr\lib\site-packages\pyVHR\analysis\stats.py:478, in StatAnalysis.__getMethods(self)
475 self.datasetNames.append(file)
476 data = pd.read_hdf(filename)
--> 478 mets.append(set(list(data['method'])))
479 dataFrame.append(data)
481 if not self.join_data:
482 # -- method names intersection among datasets
File ~\anaconda3\envs\pyvhr\lib\site-packages\pandas\core\frame.py:3505, in DataFrame.getitem(self, key) 3503 if self.columns.nlevels > 1: 3504 return self._getitem_multilevel(key) -> 3505 indexer = self.columns.get_loc(key) 3506 if is_integer(indexer): 3507 indexer = [indexer]
File ~\anaconda3\envs\pyvhr\lib\site-packages\pandas\core\indexes\base.py:3623, in Index.get_loc(self, key, method, tolerance) 3621 return self._engine.get_loc(casted_key) 3622 except KeyError as err: -> 3623 raise KeyError(key) from err 3624 except TypeError: 3625 # If we have a listlike key, _check_indexing_error will raise 3626 # InvalidIndexError. Otherwise we fall through and re-raise 3627 # the TypeError. 3628 self._check_indexing_error(key)
KeyError: 'method'
Hello @abdulkader902017, I wasn't able to reproduce your error... are you using the updated version of pyVHR? Please notice that if you installed pyVHR via pip you are using an older version (we are planning to release the newer version soon). Please try to do the following:
- clone the repo
- create the conda env as outlined in the README
- activate the env
- launch python setup.py install
Hope this will help. Cheers, Alessandro
Thanks for help @aledamelio . I think i am using the latest version found on your Github profile.
A new version of the framework, pyVHR 2.0, has been released. Please check if problems persist and report them for future bug fixes.
best the pyVHR team