wetransform-os / ProMCDA

A tool to estimate ranks of alternatives and their uncertainties based on the Multi Criteria Decision Analysis approach.
Eclipse Public License 2.0
5 stars 1 forks source link

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

Open paulrougieux opened 2 months ago

paulrougieux commented 2 months ago

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:

Flaminietta commented 1 month ago

Dear Paul,

your suggestion is a good one and would make ProMCDA another level of a tool. Our idea, also in line with your approval, is to publish the article with the current version of ProMCDA. However, the intention is to refactor ProMCDA so that it becomes a Python library, with its methods, so that it can also be used interactively and expose results.

Stay tuned! ;-)

@kapil-agnihotri @mspada