# pyrepo-mcda
The Python 3 library for Multi-Criteria Decision Analysis.
## Installation
```
pip install pyrepo-mcda
```
## Usage
`pyrepo-mcda` can be used to rank alternatives after providing their performance values in the two-dimensional decision matrix `matrix`
with alternatives in rows and criteria in columns, and criteria weights `weights` and types `types` in vectors.
All criteria weights must sum to 1. Criteria types are equal to 1 for profit criteria and -1 for cost criteria. The TOPSIS method returns a
vector with preference values `pref` assigned to alternatives. To rank alternatives according to TOPSIS preference values, we have to sort them
in descending order because, in the TOPSIS method, the best alternative has the highest preference value. The alternatives are ranked using
the `rank_preferences` method provided in the `additions` module of the `pyrepo-mcda` package. Parameter `reverse = True` means that alternatives
are sorted in descending order. Here is an example of using the TOPSIS method:
```python
import numpy as np
from pyrepo_mcda.mcda_methods import TOPSIS
from pyrepo_mcda import distance_metrics as dists
from pyrepo_mcda import normalizations as norms
from pyrepo_mcda.additions import rank_preferences
matrix = np.array([[256, 8, 41, 1.6, 1.77, 7347.16],
[256, 8, 32, 1.0, 1.8, 6919.99],
[256, 8, 53, 1.6, 1.9, 8400],
[256, 8, 41, 1.0, 1.75, 6808.9],
[512, 8, 35, 1.6, 1.7, 8479.99],
[256, 4, 35, 1.6, 1.7, 7499.99]])
weights = np.array([0.405, 0.221, 0.134, 0.199, 0.007, 0.034])
types = np.array([1, 1, 1, 1, -1, -1])
topsis = TOPSIS(normalization_method=norms.vector_normalization, distance_metric=dists.euclidean)
pref = topsis(matrix, weights, types)
rank = rank_preferences(pref, reverse = True)
print(rank)
```
## License
`pyrepo-mcda` was created by Aleksandra Bączkiewicz. It is licensed under the terms of the MIT license.
## Documentation
Documentation of this library with instruction for installation and usage is
provided [here](https://pyrepo-mcda.readthedocs.io/en/latest/)
Raw data
{
"_id": null,
"home_page": "https://github.com/energyinpython/pyrepo-mcda",
"name": "pyrepo-mcda",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "Aleksandra B\u0105czkiewicz",
"author_email": "aleksandra.baczkiewicz@phd.usz.edu.pl",
"download_url": "https://files.pythonhosted.org/packages/bd/f8/42996927a01b097daefd5a8f65b29f515165b03f1284c4dcd6a43fc24834/pyrepo_mcda-0.1.8.tar.gz",
"platform": null,
"description": "# pyrepo-mcda\r\n\r\nThe Python 3 library for Multi-Criteria Decision Analysis.\r\n\r\n## Installation\r\n\r\n```\r\npip install pyrepo-mcda\r\n```\r\n\r\n## Usage\r\n\r\n`pyrepo-mcda` can be used to rank alternatives after providing their performance values in the two-dimensional decision matrix `matrix`\r\nwith alternatives in rows and criteria in columns, and criteria weights `weights` and types `types` in vectors. \r\nAll criteria weights must sum to 1. Criteria types are equal to 1 for profit criteria and -1 for cost criteria. The TOPSIS method returns a\r\nvector with preference values `pref` assigned to alternatives. To rank alternatives according to TOPSIS preference values, we have to sort them\r\nin descending order because, in the TOPSIS method, the best alternative has the highest preference value. The alternatives are ranked using \r\nthe `rank_preferences` method provided in the `additions` module of the `pyrepo-mcda` package. Parameter `reverse = True` means that alternatives \r\nare sorted in descending order. Here is an example of using the TOPSIS method:\r\n\r\n```python\r\nimport numpy as np\r\nfrom pyrepo_mcda.mcda_methods import TOPSIS\r\nfrom pyrepo_mcda import distance_metrics as dists\r\nfrom pyrepo_mcda import normalizations as norms\r\nfrom pyrepo_mcda.additions import rank_preferences\r\n\r\nmatrix = np.array([[256, 8, 41, 1.6, 1.77, 7347.16],\r\n[256, 8, 32, 1.0, 1.8, 6919.99],\r\n[256, 8, 53, 1.6, 1.9, 8400],\r\n[256, 8, 41, 1.0, 1.75, 6808.9],\r\n[512, 8, 35, 1.6, 1.7, 8479.99],\r\n[256, 4, 35, 1.6, 1.7, 7499.99]])\r\n\r\nweights = np.array([0.405, 0.221, 0.134, 0.199, 0.007, 0.034])\r\ntypes = np.array([1, 1, 1, 1, -1, -1])\r\n\r\ntopsis = TOPSIS(normalization_method=norms.vector_normalization, distance_metric=dists.euclidean)\r\npref = topsis(matrix, weights, types)\r\nrank = rank_preferences(pref, reverse = True)\r\nprint(rank)\r\n```\r\n\r\n## License\r\n\r\n`pyrepo-mcda` was created by Aleksandra B\u0105czkiewicz. It is licensed under the terms of the MIT license.\r\n\r\n## Documentation\r\n\r\nDocumentation of this library with instruction for installation and usage is \r\nprovided [here](https://pyrepo-mcda.readthedocs.io/en/latest/)\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Python library for Multi-Criteria Decision Analysis.",
"version": "0.1.8",
"project_urls": {
"Homepage": "https://github.com/energyinpython/pyrepo-mcda"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d64ee53dc75938837c0f0a642954c90571bc055040b5fa4309928dff7f930c97",
"md5": "ea4136bf86eccc91599b5ed3fd1b61fd",
"sha256": "be8d0443018830822c0ec503795631d103d4ddc02d5c08aaec7ad5a4326d6c85"
},
"downloads": -1,
"filename": "pyrepo_mcda-0.1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ea4136bf86eccc91599b5ed3fd1b61fd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 42828,
"upload_time": "2024-08-04T18:40:19",
"upload_time_iso_8601": "2024-08-04T18:40:19.756456Z",
"url": "https://files.pythonhosted.org/packages/d6/4e/e53dc75938837c0f0a642954c90571bc055040b5fa4309928dff7f930c97/pyrepo_mcda-0.1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bdf842996927a01b097daefd5a8f65b29f515165b03f1284c4dcd6a43fc24834",
"md5": "b186ad6a64f627dec63442afd1379532",
"sha256": "7c1fc3baa8e101c483dae7e8953e450e1ffc4ad53a944dc7e8806d5f682c3f9f"
},
"downloads": -1,
"filename": "pyrepo_mcda-0.1.8.tar.gz",
"has_sig": false,
"md5_digest": "b186ad6a64f627dec63442afd1379532",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 36382,
"upload_time": "2024-08-04T18:40:21",
"upload_time_iso_8601": "2024-08-04T18:40:21.388450Z",
"url": "https://files.pythonhosted.org/packages/bd/f8/42996927a01b097daefd5a8f65b29f515165b03f1284c4dcd6a43fc24834/pyrepo_mcda-0.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-04 18:40:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "energyinpython",
"github_project": "pyrepo-mcda",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "pyrepo-mcda"
}