Skip to main content

Library for Multi-criteria Decision Aid Methods

Project description

scikit-mcda

It is a python library made to provide multi-criteria decision aid for developers and operacional researchers.

Scikit-mcda provides an easy way to apply several popular decision-making methods. It can be used as part of your development or for analytical experiments using notebooks like Jupyter, colab or kaggle. The package is available on the Pypi allowing installation by pip install scikit-mcda command.

Some methods available:

DMUU

  • laplace, hurwicz, maximax, maximin, minimax-regret ...

MCDA

  • Weighted Sum Model (WSM), Weighted Product Model (WPM) , Weighted Aggregated Sum Product Assessment (WASPAS), Technique for Order Preference by Similarity to an Ideal Solution (TOPSIS) ...

Definition of criteria weights

  • Manually, Entropy, Ranking Methods, Analytic Hierarchy Process (AHP) ...

Nomalization

  • Linear MinMax, Linear Max, Linear Sum, Vector, Enhanced Accuracy and Logarithmic.

Scikit-mcda is free to use for personal, commercial and academic projects, always respecting the terms of the Apache 2.0 License. Do not forget to refer to this Library when it is used in your experiments, lectures, presentations, classes and research papers. The reference must follow this citation format.

(HORTA, 2021)

HORTA, Antonio (2021). Scikit-mcda: The Python library for multi-criteria decision aid. 
Version 0.21. [opensource], 17 jan. 2021. Available in: https://gitlab.com/cybercrafter/scikit-mcda. 
Acessed in: 17 jan. 2021.

It's a project made by Cybercrafter® ajhorta@cybercrafter.com.br

Module for Decision-making Under Uncertainty (DMUU)

DMUU: Class Module for Decision-making Under Uncertainty

Attributes:

df_original = DataFrame
df_calc = DataFrame
decision = {"alternative":,
            "index":,
            "value": ,
            "criteria": ,
            "result": ,
            "type_dm": "DMUU",
            "hurwicz_coeficient":}

Criteria Methods:

  • maximax()
  • maximin()
  • laplace()
  • minimax_regret()
  • hurwicz(coef)

Properties

  • pretty_original(tablefmt='psql')
  • pretty_calc(tablefmt='psql')
  • pretty_decision(tablefmt='psql')

tablefmt: "psql" or "latex" or "html"

Methods:

  • dataframe(alt_data, alt_labels=[], state_labels=[])
  • decision_making(dmuu_criteria_list=[])

Quick Start for DMUU

from scikitmcda.dmuu import DMUU

# Defining labels for Alternatives and States")

dmuu = DMUU()

dmuu.dataframe([[5000, 2000, 100],
                [50, 50, 500]],
                ["ALT_A", "ALT_B"],
                ["STATE A", "STATE B", "STATE C"]
                )

print(dmuu.pretty_original())
+----+----------------+-----------+-----------+-----------+
|    | alternatives   |   STATE A |   STATE B |   STATE C |
|----+----------------+-----------+-----------+-----------|
|  0 | ALT_A          |      5000 |      2000 |       100 |
|  1 | ALT_B          |        50 |        50 |       500 |
+----+----------------+-----------+-----------+-----------+

# Specifying the criteria method

dmuu.minimax_regret()

print(dmuu.pretty_calc())
+----+----------------+-----------+-----------+-----------+------------------+
|    | alternatives   |   STATE A |   STATE B |   STATE C | minimax-regret   |
|----+----------------+-----------+-----------+-----------+------------------|
|  0 | ALT_A          |      5000 |      2000 |       100 | (400, 1)         |
|  1 | ALT_B          |        50 |        50 |       500 | (4950, 0)        |
+----+----------------+-----------+-----------+-----------+------------------+

print(dmuu.pretty_decision())
+---------------+---------+---------+----------------+-------------------------------+-----------+----------------------+
| alternative   |   index |   value | criteria       | result                        | type_dm   | hurwicz_coeficient   |
|---------------+---------+---------+----------------+-------------------------------+-----------+----------------------|
| ALT_A         |       0 |     400 | minimax-regret | {'ALT_A': 400, 'ALT_B': 4950} | DMUU      |                      |
+---------------+---------+---------+----------------+-------------------------------+-----------+----------------------+

# Many crietria methods

dmuu.decision_making([dmuu.maximax(), dmuu.maximin(), dmuu.hurwicz(0.8), dmuu.minimax_regret()])

print(dmuu.pretty_calc())
+----+----------------+-----------+-----------+-----------+------------------+-----------+-----------+------------------+
|    | alternatives   |   STATE A |   STATE B |   STATE C | minimax-regret   | maximax   | maximin   | hurwicz          |
|----+----------------+-----------+-----------+-----------+------------------+-----------+-----------+------------------|
|  0 | ALT_A          |      5000 |      2000 |       100 | (400, 1)         | (5000, 1) | (100, 1)  | (4020.0, 1, 0.8) |
|  1 | ALT_B          |        50 |        50 |       500 | (4950, 0)        | (500, 0)  | (50, 0)   | (410.0, 0, 0.8)  |
+----+----------------+-----------+-----------+-----------+------------------+-----------+-----------+------------------+

print(dmuu.pretty_decision())
+---------------+---------+---------+----------------+-----------------------------------+-----------+----------------------+
| alternative   |   index |   value | criteria       | result                            | type_dm   | hurwicz_coeficient   |
|---------------+---------+---------+----------------+-----------------------------------+-----------+----------------------|
| ALT_A         |       0 |    5000 | maximax        | {'ALT_A': 5000, 'ALT_B': 500}     | DMUU      |                      |
| ALT_A         |       0 |     100 | maximin        | {'ALT_A': 100, 'ALT_B': 50}       | DMUU      |                      |
| ALT_A         |       0 |    4020 | hurwicz        | {'ALT_A': 4020.0, 'ALT_B': 410.0} | DMUU      | 0.8                  |
| ALT_A         |       0 |     400 | minimax-regret | {'ALT_A': 400, 'ALT_B': 4950}     | DMUU      |                      |
+---------------+---------+---------+----------------+-----------------------------------+-----------+----------------------+

dmuu.calc_clean()
print(dmuu.pretty_calc())
+----+----------------+-----------+-----------+-----------+
|    | alternatives   |   STATE A |   STATE B |   STATE C |
|----+----------------+-----------+-----------+-----------|
|  0 | ALT_A          |      5000 |      2000 |       100 |
|  1 | ALT_B          |        50 |        50 |       500 |
+----+----------------+-----------+-----------+-----------+

Module for Multi-Criteria Decision Aid (MCDA)

MCDA: Class Module for Multi-Criteria Decision-Aid

Attributes:

  • df_original
  • weights
  • signals
  • df_normalized
  • df_weighted
  • df_pis
  • df_nis
  • df_distances
  • df_decision

MCDA basis methods:

  • dataframe(alt_data, alt_labels=[], state_labels=[])
  • set_signals([MIN, MIN, MAX])

MCDA weights determination methods:

  • set_weights_manually([])
  • set_weights_by_entropy(normalization_method_for_entropy=LinearSum_)
  • set_weights_by_ranking_A()
  • set_weights_by_ranking_B()
  • set_weights_by_ranking_B_POW(default=0)
  • set_weights_by_ranking_C()
  • set_weights_by_AHP(saaty_preference_matrix)

Ranking methods A, B, B_POW and C need criteria ordered by importance C1> c2> C3 ...

Decision-Making methods:

  • topsis(normalization_method=TopsisOriginal_)
  • wsm(normalization_method=None)
  • wpm(normalization_method=None)
  • waspas(lambda=0.5, normalization_method=None)

Normalization constants: LinearMinMax_, LinearMax_, LinearSum_, Vector_, EnhancedAccuracy_ and Logarithmic_

Properties

  • pretty_original(tablefmt='psql')
  • pretty_normalized(tablefmt='psql')
  • pretty_weighted(tablefmt='psql')
  • pretty_Xis(tablefmt='psql')
  • pretty_decision(tablefmt='psql')

tablefmt: "psql" or "latex" or "html"

Quick Start for MCDA

from scikitmcda.mcda import MCDA
from scikitmcda.constants import MAX, MIN, ZScore_, MinMax_, Logistic_, Max_, Sum_, RootSumSquared_ 

mcda = MCDA()

mcda.dataframe([[250, 16, 12, 5],
                [200, 16,  8, 3],
                [300, 32, 16, 4],
                [275, 32,  8, 4],
                [225, 16,  16, 2]],
               ["Mobile 1", "Mobile 2", "Mobile 3", "Mobile 4", "Mobile 5"],
               ["COST", "STORAGE", "CAMERA", "DESIGN"]
               )
print(mcda.pretty_original())
+----+----------------+--------+-----------+----------+----------+
|    | alternatives   |   COST |   STORAGE |   CAMERA |   DESIGN |
|----+----------------+--------+-----------+----------+----------|
|  0 | Mobile 1       |    250 |        16 |       12 |        5 |
|  1 | Mobile 2       |    200 |        16 |        8 |        3 |
|  2 | Mobile 3       |    300 |        32 |       16 |        4 |
|  3 | Mobile 4       |    275 |        32 |        8 |        4 |
|  4 | Mobile 5       |    225 |        16 |       16 |        2 |
+----+----------------+--------+-----------+----------+----------+

# mcda.set_weights_manually([0.5918, 0.2394, 0.1151, 0.0537])
# mcda.set_weights_by_entropy()
# mcda.set_weights_by_ranking_B_POW(0)

                                 # C1   C2     C3   C4 
w_AHP = mcda.set_weights_by_AHP([[  1,    4,    5,   7],   # C1
                                 [1/4,    1,    3,   5],   # C2
                                 [1/5,  1/3,    1,   3],   # C3
                                 [1/7,  1/5,  1/3,   1]])  # C4
print("AHP Returned:\n", w_AHP)
print("WEIGHTS:\n", mcda.weights)

AHP Returned:
{'consistency': True, 'lambda': 4.17992665646019, 'CIndex': 0.05997555215339675, 'CRatio': 0.06663950239266306}

WEIGHTS:
[0.5809771356405764, 0.2429005339101441, 0.12011108977871769, 0.056011240670561804]

mcda.set_signals([MIN, MAX, MAX, MAX])

mcda.topsis()
print("NORMALIZED:\n", mcda.pretty_normalized())

NORMALIZED:
+----+----------------+----------+-----------+----------+----------+
|    | alternatives   |     COST |   STORAGE |   CAMERA |   DESIGN |
|----+----------------+----------+-----------+----------+----------|
|  0 | Mobile 1       | 0.442807 |  0.301511 | 0.428571 | 0.597614 |
|  1 | Mobile 2       | 0.354246 |  0.301511 | 0.285714 | 0.358569 |
|  2 | Mobile 3       | 0.531369 |  0.603023 | 0.571429 | 0.478091 |
|  3 | Mobile 4       | 0.487088 |  0.603023 | 0.285714 | 0.478091 |
|  4 | Mobile 5       | 0.398527 |  0.301511 | 0.571429 | 0.239046 |
+----+----------------+----------+-----------+----------+----------+

print("WEIGHTED:\n", mcda.pretty_weighted())

WEIGHTED:
+----+----------------+----------+-----------+-----------+-----------+
|    | alternatives   |     COST |   STORAGE |    CAMERA |    DESIGN |
|----+----------------+----------+-----------+-----------+-----------|
|  0 | Mobile 1       | 0.257261 | 0.0732373 | 0.0514762 | 0.0334731 |
|  1 | Mobile 2       | 0.205809 | 0.0732373 | 0.0343175 | 0.0200839 |
|  2 | Mobile 3       | 0.308713 | 0.146475  | 0.0686349 | 0.0267785 |
|  3 | Mobile 4       | 0.282987 | 0.146475  | 0.0343175 | 0.0267785 |
|  4 | Mobile 5       | 0.231535 | 0.0732373 | 0.0686349 | 0.0133892 |
+----+----------------+----------+-----------+-----------+-----------+

print("IDEAL SOLUTIONS:\n", mcda.pretty_Xis())

IDEAL SOLUTIONS:
+-----+----------+-----------+-----------+-----------+
|     |     COST |   STORAGE |    CAMERA |    DESIGN |
|-----+----------+-----------+-----------+-----------|
| PIS | 0.205809 | 0.146475  | 0.0686349 | 0.0334731 |
| NIS | 0.308713 | 0.0732373 | 0.0343175 | 0.0133892 |
+-----+----------+-----------+-----------+-----------+

print("RANKING TOPSIS with", mcda.normalization_method , ":\n", mcda.pretty_decision())

RANKING TOPSIS with Vector_ :
+----+----------------+---------------------+--------+
|    | alternatives   |   performance score |   rank |
|----+----------------+---------------------+--------|
|  0 | Mobile 2       |            0.55711  |      1 |
|  1 | Mobile 5       |            0.513009 |      2 |
|  2 | Mobile 4       |            0.481779 |      3 |
|  3 | Mobile 3       |            0.44289  |      4 |
|  4 | Mobile 1       |            0.388243 |      5 |
+----+----------------+---------------------+--------+

mcda.topsis(LinearMinMax_)
print("RANKING TOPSIS with", mcda.normalization_method, ":\n", mcda.pretty_decision())

RANKING TOPSIS with LinearMinMax :
+----+----------------+---------------------+--------+
|    | alternatives   |   performance score |   rank |
|----+----------------+---------------------+--------|
|  0 | Mobile 2       |            0.680005 |      1 |
|  1 | Mobile 5       |            0.610388 |      2 |
|  2 | Mobile 1       |            0.440519 |      3 |
|  3 | Mobile 4       |            0.386897 |      4 |
|  4 | Mobile 3       |            0.319995 |      5 |
+----+----------------+---------------------+--------+

mcda.waspas(0.5, Vector_)
print("RANKING WASPAS with", mcda.normalization_method, ":\n", mcda.pretty_decision())

RANKING WASPAS with Vector :
+----+----------------+-------------------+--------+
|    | alternatives   |   WASPAS (λ 0.5 ) |   rank |
|----+----------------+-------------------+--------|
|  0 | Mobile 3       |          0.275342 |      1 |
|  1 | Mobile 4       |          0.245298 |      2 |
|  2 | Mobile 1       |          0.20774  |      3 |
|  3 | Mobile 5       |          0.193406 |      4 |
|  4 | Mobile 2       |          0.166729 |      5 |
+----+----------------+-------------------+--------+

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scikit-mcda-0.21.16.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

scikit_mcda-0.21.16-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file scikit-mcda-0.21.16.tar.gz.

File metadata

  • Download URL: scikit-mcda-0.21.16.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.22.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for scikit-mcda-0.21.16.tar.gz
Algorithm Hash digest
SHA256 e3b5fac58db5f8124ed730eb4723a74048fae7e634d00525e8becdd67e74acf3
MD5 0dbdb5162811c4d7037214871af64fb0
BLAKE2b-256 6aae5cc44653bd416c436815e709273573df83a68137bf7e0b567b9a29929051

See more details on using hashes here.

Provenance

File details

Details for the file scikit_mcda-0.21.16-py3-none-any.whl.

File metadata

  • Download URL: scikit_mcda-0.21.16-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.22.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for scikit_mcda-0.21.16-py3-none-any.whl
Algorithm Hash digest
SHA256 cd2f50257f68a583a3b37ebdd9145da65cb78017413b72a0cf2ffc88b556014f
MD5 ed29559baf8cb90aad6dfdc3c0686c66
BLAKE2b-256 dd6774cc954b5b85078e86764e57d2848201b90616597bb704d9321db86c4c3e

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page