Skip to content

Run interactively and make the scores data frames available to the user directly #52

@paulrougieux

Description

@paulrougieux

Python is an interactive language. It would be nice to have access to the objects and data frames used during the computation. The current version writes the scores data frames to csv files which can be then opened in a spreadsheet, but what if the user wants to open them in python for further processing or comparison with other tools?

Current status

For example the data frames scores and normalised_scores are written to csv files in
utils_for_main.py#L1201. The current version runs as a standalone script as explained in the example in REAMDE.md. It then exits with the following log :

python3 -m mcda.mcda_run -c configuration.json

INFO: 2024-09-10 11:57:36,015 - ProMCDA - Reading the input matrix in ./input_files/toy_example/car_data.csv
INFO: 2024-09-10 11:57:36,020 - ProMCDA - ProMCDA will only use one pair of norm/agg functions: minmax/weighted_sum
INFO: 2024-09-10 11:57:36,020 - ProMCDA - ProMCDA will run without uncertainty on the indicators or weights
INFO: 2024-09-10 11:57:36,020 - ProMCDA - Read input matrix without uncertainties at toy_example/car_data.csv
INFO: 2024-09-10 11:57:36,021 - ProMCDA - Duplicated rows in the alternatives column.
INFO: 2024-09-10 11:57:36,021 - ProMCDA - Alternatives are ['A', 'B', 'C', 'D', 'E', 'F']
INFO: 2024-09-10 11:57:36,024 - ProMCDA - Number of alternatives: 6
INFO: 2024-09-10 11:57:36,024 - ProMCDA - Number of indicators: 6
INFO: 2024-09-10 11:57:36,024 - ProMCDA - Polarities: ['+', '+', '-', '+', '+', '+']
INFO: 2024-09-10 11:57:36,024 - ProMCDA - Weights: [0.8, 0.9, 0.5, 0.5, 0.1, 0.7]
INFO: 2024-09-10 11:57:36,024 - ProMCDA - Normalized weights: [0.2285714285714286, 0.2571428571428572, 0.14285714285714285, 0.14285714285714285, 0.028571428571428574, 0.19999999999999998]
INFO: 2024-09-10 11:57:36,024 - ProMCDA - Start ProMCDA without robustness of the indicators
INFO: 2024-09-10 11:57:36,035 - ProMCDA - Saving results in ./output_files/toy_example
INFO: 2024-09-10 11:57:38,257 - ProMCDA - ProMCDA finished calculations: check the output files
INFO: 2024-09-10 11:57:38,258 - ProMCDA - All calculations finished in seconds 2.2425341606140137

Proposal

It would be great to have direct access to the scores data frame in an interactive session. The README could explain how to run mcda in an interactive python session or notebook by importing it in python with an import statement such as

from mcda.mcda_run import main

Note:

  • Exposing the scores data frames probably requires a rewrite of the package to expose those data frame to the user
  • main is probably not a good function name in this new use case. The function should be renamed to mcda_run for example. Then it should probably refactored into an object which has properties that contain the scores data frame. For example one would access the mcda_run object properties from within the python session (or notebook) with mcda_run.scores.
  • It is related to the JOSS review [REVIEW]: ProMCDA: A Python package for Probabilistic Multi-Criteria Decision Analysis openjournals/joss-reviews#6190, but is not a blocker for the release of the package just an improvement suggestion.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions