Refactor Training Cell #89

Merged
nuluh merged 1 commits from feature/88-refactor-training-cell into dev 2025-05-29 16:04:24 +00:00
nuluh commented 2025-05-29 16:03:37 +00:00 (Migrated from github.com)

This pull request refactors the code/notebooks/stft.ipynb file to simplify the codebase, improve maintainability, and enhance the clarity of model training and evaluation logic. The changes include consolidating repetitive code into reusable functions, restructuring the model definitions, and improving the visualization process.

Code Simplification and Refactoring:

  • Consolidated repetitive model training and evaluation logic into a reusable function train_and_evaluate_model, reducing code duplication and improving readability.

  • Restructured model definitions into dictionaries (models_sensor1 and models_sensor2) for each sensor, allowing dynamic iteration over models and enhancing flexibility.

Visualization Enhancements:

  • Refactored the plotting logic by introducing helper functions prepare_plot_data and plot_accuracies to streamline the process of generating bar plots for model accuracies across sensors. This improves modularity and reduces clutter.

Code Cleanup:

  • Removed redundant imports and unused code, including the previous hardcoded plotting logic and model accuracy calculations, to declutter the notebook.…e_model`
This pull request refactors the `code/notebooks/stft.ipynb` file to simplify the codebase, improve maintainability, and enhance the clarity of model training and evaluation logic. The changes include consolidating repetitive code into reusable functions, restructuring the model definitions, and improving the visualization process. ### Code Simplification and Refactoring: * Consolidated repetitive model training and evaluation logic into a reusable function `train_and_evaluate_model`, reducing code duplication and improving readability. * Restructured model definitions into dictionaries (`models_sensor1` and `models_sensor2`) for each sensor, allowing dynamic iteration over models and enhancing flexibility. ### Visualization Enhancements: * Refactored the plotting logic by introducing helper functions `prepare_plot_data` and `plot_accuracies` to streamline the process of generating bar plots for model accuracies across sensors. This improves modularity and reduces clutter. ### Code Cleanup: * Removed redundant imports and unused code, including the previous hardcoded plotting logic and model accuracy calculations, to declutter the notebook.…e_model`
Sign in to join this conversation.