If you use scikit-criteria or the AHP extension in a scientific publication or thesis, we would appreciate citations to the following paper:
Cabral, Juan B., Nadia Ayelen Luczywo, and José Luis Zanazzi 2016 Scikit-Criteria: Colección de Métodos de Análisis Multi-Criterio Integrado Al Stack Científico de Python. In XLV Jornadas Argentinas de Informática E Investigación Operativa (45JAIIO)-XIV Simposio Argentino de Investigación Operativa (SIO) (Buenos Aires, 2016) Pp. 59–66. http://45jaiio.sadio.org.ar/sites/default/files/Sio-23.pdf.
Bibtex entry:
@inproceedings{scikit-criteria,
author={
Juan B Cabral and Nadia Ayelen Luczywo and Jos\'{e} Luis Zanazzi},
title={
Scikit-Criteria: Colecci\'{o}n de m\'{e}todos de an\'{a}lisis
multi-criterio integrado al stack cient\'{i}fico de {P}ython},
booktitle = {
XLV Jornadas Argentinas de Inform{\'a}tica
e Investigaci{\'o}n Operativa (45JAIIO)-
XIV Simposio Argentino de Investigaci\'{o}n Operativa (SIO)
(Buenos Aires, 2016)},
year={2016},
pages = {59--66},
url={http://45jaiio.sadio.org.ar/sites/default/files/Sio-23.pdf}
}
The main problem is how the data are feeded to AHP. All the methods included in Scikit-Criteria uses the clasical
$$ SkC_{madm}(mtx, criteria, weights) $$Where
All this 3 components can be modeled as the single scikit-criteria DATA object:
In [3]:
from skcriteria import Data, MIN, MAX
In [5]:
mtx = [
[1, 2, 3], # alternative 1
[4, 5, 6], # alternative 2
]
mtx
Out[5]:
In [6]:
# let's says the first two alternatives are
# for maximization and the last one for minimization
criteria = [MAX, MAX, MIN]
criteria
Out[6]:
In [7]:
# et’s asume we know in our case, that the importance of
# the autonomy is the 50%, the confort only a 5% and
# the price is 45%
weights=[.5, .05, .45]
weights
Out[7]:
In [9]:
data = Data(mtx, criteria, weights)
data
Out[9]:
In other hand AHP uses as an in put 2 totally different
$$ AHP(CvC, AvA) $$Where:
first we need to import the ahp module
In [24]:
import ahp
The function ahp.t
(from triangular) accept the lower half of the mattrix and return a complete mattrix with the reciprocal values
In [25]:
mtx = ahp.t(
[[1],
[1., 1],
[1/3.0, 1/6.0, 1]])
mtx
Out[25]:
You can validate if some mattrix has the correct values for AHP with the function
ahp.validate_ahp_matrix(n, mtx)
Where:
n
: is the number of rows and columns (remember all mattrix in AHP has the same rows and columns).mtx
: The mattrix to validate.
In [26]:
# this validate the data
ahp.validate_ahp_matrix(3, mtx)
In [28]:
invalid_mtx = mtx.copy()
invalid_mtx[0, 1] = 89
invalid_mtx
Out[28]:
In [29]:
ahp.validate_ahp_matrix(3, invalid_mtx)
In [32]:
invalid_mtx = mtx.copy()
invalid_mtx[0, 1] = 0.5
invalid_mtx
Out[32]:
In [33]:
ahp.validate_ahp_matrix(3, invalid_mtx)
In [35]:
crit_vs_crit = ahp.t([
[1.],
[1./3., 1.],
[1./3., 1./2., 1.]
])
crit_vs_crit
Out[35]:
And lets asume we have 3 alternatives, and because we have 3 criteria: 3 alternatives vs alternatives mattrix must be created
In [36]:
alt_vs_alt_by_crit = [
ahp.t([[1.],
[1./5., 1.],
[1./3., 3., 1.]]),
ahp.t([
[1.],
[9., 1.],
[3., 1./5., 1.]]),
ahp.t([[1.],
[1/2., 1.],
[5., 7., 1.]]),
]
alt_vs_alt_by_crit
Out[36]:
Now run th ahp.ahp()
function. This function return 6 values
rank
).points
).crit_ci
)avabc_ci
)crit_cr
).
ranked, points, crit_ci, avabc_ci, crit_cr, avabc_cravabc_cr
)
In [49]:
result = ahp.ahp(crit_vs_crit, alt_vs_alt_by_crit)
rank, points, crit_ci, avabc_ci, crit_cr, avabc_cr = result
In [50]:
rank
Out[50]:
So ouer best altetnative is the first one, and the worst is the second one
The final points of every alternative is:
In [51]:
points
Out[51]: