som-shahlab / aplusml

APLUS ML = A Python Library for Usefulness Simulations of Machine Learning models
Apache License 2.0
19 stars 3 forks source link

Added seismometer data format support #8

Closed alisoncallahan closed 3 months ago

alisoncallahan commented 3 months ago

Updated sim.py and pad.py to support seismometer data format. Created synthetic_pad_seismometer.ipynb and required seismometer files to demonstrate functionality.

Miking98 commented 3 months ago

Overall looks good!

I had one issue with the pad ipynb, though, of it not finding the data/metadata.json path. Do you know why this might be the case?

Line of code:

# run Seismometer startup to generate Seismometer formatted data
sm.run_startup(config_path="./seismometer/", predictions_frame=df_merged)

Error:

FileNotFoundError                         Traceback (most recent call last)
Cell In[11], line 2
      1 # run Seismometer startup to generate Seismometer formatted data
----> 2 sm.run_startup(config_path="./seismometer/", predictions_frame=df_merged)

File ~/anaconda3/envs/aplus/lib/python3.10/site-packages/seismometer/__init__.py:65, in run_startup(config_path, output_path, predictions_frame, events_frame, definitions, log_level, reset)
     63 loader = loader_factory(config)
     64 sg = Seismogram(config, loader)
---> 65 sg.load_data(predictions=predictions_frame, events=events_frame)
     67 # Surface api into namespace
     68 s_module = importlib.import_module("seismometer._api")

File ~/anaconda3/envs/aplus/lib/python3.10/site-packages/seismometer/seismogram.py:98, in Seismogram.load_data(self, predictions, events, reset)
     95     logger.debug("Data already loaded; pass reset=True to clear data and re-evaluate.")
     96     return
---> 98 self._load_metadata()
    100 self.dataframe = self.dataloader.load_data(predictions, events)
    102 self.create_cohorts()

File ~/anaconda3/envs/aplus/lib/python3.10/site-packages/seismometer/seismogram.py:335, in Seismogram._load_metadata(self)
    330 def _load_metadata(self):
    331     """
    332     Loads metadata including model name (by default, "UNDEFINED MODEL") and set of threshold values
    333     (by default, [0.8, 0.5]) to display on performance plots.
    334     """
--> 335     with open(self.config.metadata_path, "r") as file:
    336         self._metadata = json.load(file)
    337     try:

FileNotFoundError: [Errno 2] No such file or directory: 'data/metadata.json'
alisoncallahan commented 3 months ago

@Miking98 you're seeing this error with synthetic_pad.ipynb? I removed all the seismometer testing code from that notebook (just added one more change, but it doesn't affect the above), so it should be good to go.

Miking98 commented 3 months ago

Seems to be an issue with the seismometer library not running os.path.join() on the data dir and metadata_path in config.yml -- will open an issue there to fix (APLUS code looks good to me)