-
Notifications
You must be signed in to change notification settings - Fork 244
Unifying Python and R plots
Joshua Olaoye edited this page Feb 26, 2025
·
1 revision
The previous implementation of the Python and R scripts in plotscode had redundant logic spread across six different files. Specifically, the backward.py and backward.R scripts performed the same operations as forward.py and forward.R, but for different datasets
We introduced a requirements.R script. Running this script will install all necessary dependencies required to execute the R scripts within the plotscode directory
- The
BrainWaveAnalysisclass constructor required a single file path as input
- The constructor now accepts:
- A collection of categories:
backward,forward,land,left,right, andtakeoff - A base file path, which points to the root directory containing the
brainwaves-csvdataset
- A collection of categories:
- Add a
process_all_categoriesmethod that sequentially processes each category - Enhance the
plotmethod to create a new directory for storing generated plots
Since process_all_categories processes each category using existing methods, we consolidated all the logic into a single method, analyze_category, which:
- Takes a
filepathas input - Integrates the functionalities of multiple functions:
clean_datareshape_databin_dataprepare_for_plottingfit_modelpredict_data
Previously, the Python scripts only had one responsibility: executing the R script. To improve extensibility, we introduced a Controller class:
- The constructor takes the file path of the R script.
- The
execute_r_scriptmethod usesrpy2to run the R script.