Subpackages

Submodules

pymcdm.correlations module

pymcdm.correlations.correlation_matrix(rankings, method, columns=False)

Creates a correlation matrix for given vectors from the numpy array.

Parameters
  • rankings (ndarray) – Vectors for which the correlation matrix is to be calculated.

  • method (callable) – Function to calculate the correlation matrix.

  • columns (bool) – If the column value is set to true then the correlation matrix will be calculated for the columns. Otherwise the matrix will be calculated for the rows.

Returns

Correlation between two rankings vectors.

Return type

ndarray

pymcdm.correlations.goodman_kruskal_gamma(x, y)

Calculate Goodman’s and Kruskal’s Gamma correlation between two rankings vectors.

Parameters
  • x (ndarray) – First vector of ranks.

  • y (ndarray) – Second vector of ranks.

Returns

Correlation between two rankings vectors.

Return type

float

pymcdm.correlations.kendall_tau(x, y)

Calculate Kendall Tau correlation between two rankings vectors.

Parameters
  • x (ndarray) – First vector of ranks.

  • y (ndarray) – Second vector of ranks.

Returns

Correlation between two rankings vectors.

Return type

float

pymcdm.correlations.pearson(x, y)

Calculate Pearson correlation between two raw vectors.

Parameters
  • x (ndarray) – First vector with raw values.

  • y (ndarray) – Second vector with raw values.

Returns

Correlation between two vectors.

Return type

float

pymcdm.correlations.rank_similarity_coef(x, y)

Calculate Rank Similarity Coefficient (WS) between two rankings vectors.

Parameters
  • x (ndarray) – First vector of ranks.

  • y (ndarray) – Second vector of ranks.

Returns

Correlation between two rankings vectors.

Return type

float

pymcdm.correlations.spearman(x, y)

Calculate Spearman correlation between two rankings vectors.

Parameters
  • x (ndarray) – First vector of ranks.

  • y (ndarray) – Second vector of ranks.

Returns

Correlation between two rankings vectors.

Return type

float

pymcdm.correlations.weighted_spearman(x, y)

Calculate Weighted Spearman correlation between two rankings vectors.

Parameters
  • x (ndarray) – First vector of ranks.

  • y (ndarray) – Second vector of ranks.

Returns

Correlation between two rankings vectors.

Return type

float

pymcdm.helpers module

pymcdm.helpers.correlation_matrix(rankings, method, columns=False)

Creates a correlation matrix for given vectors from the numpy array.

Parameters
  • rankings (ndarray) – Vectors for which the correlation matrix is to be calculated.

  • method (callable) – Function to calculate the correlation matrix.

  • columns (bool) – If the column value is set to true then the correlation matrix will be calculated for the columns. Otherwise the matrix will be calculated for the rows.

Returns

Correlation between two rankings vectors.

Return type

ndarray

pymcdm.helpers.normalize_matrix(matrix, method, criteria_types)

Normalize each column in matrix, using normalization function according criteria_types.

Parameters
  • matrix (ndarray) – Decision matrix representation. The rows are considered as alternatives and the columns are considered as criteria.

  • normalization (callable) – Function which should be used for normalize matrix columns. It should match signature foo(x, cost), where x is a vector which would be normalized and cost is a bool variable which says if x is a cost or profit criteria.

  • criteria_types (None or ndarray) – Describes criteria types. 1 if criteria is profit and -1 if criteria is cost for each criteria in matrix. If None all criteria are considered as profit

Returns

Normalized copy of the input matrix.

Return type

ndarray

Raises

ValueError – If criteria_types and matrix has different number of criteria.

pymcdm.helpers.rankdata(a, reverse=False)

Assign ranks to data in vector a.

Ranks begin at 1. Tied elements get average rank (see Examples below).

Ranking starts from smaller values, e.g. the smaller element get the first position. The reverse argument reverse posisions, e.g. the largest element get first position.

Parameters
  • a (iterable) – The array of values to be ranked.

  • reverse (bool, optional) – If True, larger elements get first posisions in ranking. If False, smaller elements get first positions in ranking.

Returns

An array of rank scores for the input data.

Return type

ndarray

Examples

>>> from pymcdm.helpers import rankdata
>>> rankdata([0, 3, 2, 5])
array([1, 3, 2, 4])
>>> rankdata([0, 3, 2, 5], reverse=True)
array([4, 2, 3, 1])
>>> rankdata([0, 3, 2, 3])
array([1. , 3.5, 2. , 3.5])
>>> rankdata([0, 3, 2, 3], reverse=True)
array([4. , 1.5, 3. , 1.5])
pymcdm.helpers.rrankdata(a)

Alias to rankdata(a, reverse=True). See rankdata for details.

pymcdm.normalizations module

pymcdm.normalizations.enhanced_accuracy_normalization(x, cost=False)

Calculate the normalized vector using the enhanced accuracy method.

Parameters
  • x (ndarray) – One-dimensional numpy array of values to be normalized

  • cost (bool, optional) – Vector type. Default profit type.

Returns

One-dimensional numpy array of normalized values.

Return type

ndarray

pymcdm.normalizations.linear_normalization(x, cost=False)

Calculate the normalized vector using the linear method.

Parameters
  • x (ndarray) – One-dimensional numpy array of values to be normalized

  • cost (bool, optional) – Vector type. Default profit type.

Returns

One-dimensional numpy array of normalized values.

Return type

ndarray

pymcdm.normalizations.logarithmic_normalization(x, cost=False)

Calculate the normalized vector using the logarithmic method.

Parameters
  • x (ndarray) – One-dimensional numpy array of values to be normalized

  • cost (bool, optional) – Vector type. Default profit type.

Returns

One-dimensional numpy array of normalized values.

Return type

ndarray

pymcdm.normalizations.max_normalization(x, cost=False)

Calculate the normalized vector using the max method.

Parameters
  • x (ndarray) – One-dimensional numpy array of values to be normalized

  • cost (bool, optional) – Vector type. Default profit type.

Returns

One-dimensional numpy array of normalized values.

Return type

ndarray

pymcdm.normalizations.minmax_normalization(x, cost=False)

Calculate the normalized vector using the min-max method.

Parameters
  • x (ndarray) – One-dimensional numpy array of values to be normalized

  • cost (bool, optional) – Vector type. Default profit type.

Returns

One-dimensional numpy array of normalized values.

Return type

ndarray

pymcdm.normalizations.nonlinear_normalization(x, cost=False)

Calculate the normalized vector using the nonlinear method.

Parameters
  • x (ndarray) – One-dimensional numpy array of values to be normalized

  • cost (bool, optional) – Vector type. Default profit type.

Returns

One-dimensional numpy array of normalized values.

Return type

ndarray

pymcdm.normalizations.sum_normalization(x, cost=False)

Calculate the normalized vector using the sum method.

Parameters
  • x (ndarray) – One-dimensional numpy array of values to be normalized

  • cost (bool, optional) – Vector type. Default profit type.

Returns

One-dimensional numpy array of normalized values.

Return type

ndarray

pymcdm.normalizations.vector_normalization(x, cost=False)

Calculate the normalized vector using the vector method.

Parameters
  • x (ndarray) – One-dimensional numpy array of values to be normalized

  • cost (bool, optional) – Vector type. Default profit type.

Returns

One-dimensional numpy array of normalized values.

Return type

ndarray

pymcdm.normalizations.zavadskas_turskis_normalization(x, cost=False)

Calculate the normalized vector using the Zavadskas-Turskis method.

Parameters
  • x (ndarray) – One-dimensional numpy array of values to be normalized

  • cost (bool, optional) – Vector type. Default profit type.

Returns

One-dimensional numpy array of normalized values.

Return type

ndarray

pymcdm.weights module

pymcdm.weights.angle_weights(matrix, *args, **kwargs)

Calculate weights for given matrix using angle method.

Parameters

matrix (ndarray) – Decision matrix / alternatives data. Alternatives are in rows and Criteria are in columns.

Returns

Vector of weights.

Return type

ndarray

pymcdm.weights.cilos_weights(matrix, types, *args, **kwargs)

Calculate weights for given matrix using CILOS method.

Parameters
  • matrix (ndarray) – Decision matrix / alternatives data. Alternatives are in rows and Criteria are in columns.

  • types (ndarray) – Array with definitions of criteria types: 1 if criteria is profit and -1 if criteria is cost for each criteria in matrix.

Returns

Vector of weights.

Return type

ndarray

pymcdm.weights.critic_weights(matrix, *args, **kwargs)

Calculate weights for given matrix using CRITIC method.

Parameters

matrix (ndarray) – Decision matrix / alternatives data. Alternatives are in rows and Criteria are in columns.

Returns

Vector of weights.

Return type

ndarray

pymcdm.weights.entropy_weights(matrix, *args, **kwargs)

Calculate weights for given matrix using entropy method.

Parameters

matrix (ndarray) – Decision matrix / alternatives data. Alternatives are in rows and Criteria are in columns.

Returns

Vector of weights.

Return type

ndarray

pymcdm.weights.equal_weights(matrix, *args, **kwargs)

Calculate equal weights for given matrix.

Parameters

matrix (ndarray) – Decision matrix / alternatives data. Alternatives are in rows and Criteria are in columns.

Returns

Vector of weights.

Return type

ndarray

pymcdm.weights.gini_weights(matrix, *args, **kwargs)

Calculate weights for given matrix using gini method.

Parameters

matrix (ndarray) – Decision matrix / alternatives data. Alternatives are in rows and Criteria are in columns.

Returns

Vector of weights.

Return type

ndarray

pymcdm.weights.idocriw_weights(matrix, types, *args, **kwargs)

Calculate weights for given matrix using IDOCRIW method.

Parameters
  • matrix (ndarray) – Decision matrix / alternatives data. Alternatives are in rows and Criteria are in columns.

  • types (ndarray) – Array with definitions of criteria types: 1 if criteria is profit and -1 if criteria is cost for each criteria in matrix.

Returns

Vector of weights.

Return type

ndarray

pymcdm.weights.merec_weights(matrix, types, *args, **kwargs)

Calculate weights for given matrix using MEREC method.

Parameters
  • matrix (ndarray) – Decision matrix / alternatives data. Alternatives are in rows and Criteria are in columns.

  • types (ndarray) – Array with definitions of criteria types: 1 if criteria is profit and -1 if criteria is cost for each criteria in matrix.

Returns

Vector of weights.

Return type

ndarray

pymcdm.weights.standard_deviation_weights(matrix, *args, **kwargs)

Calculate weights for given matrix using std method.

Parameters

matrix (ndarray) – Decision matrix / alternatives data. Alternatives are in rows and Criteria are in columns.

Returns

Vector of weights.

Return type

ndarray

pymcdm.weights.variance_weights(matrix, *args, **kwargs)

Calculate weights for given matrix using std method.

Parameters

matrix (ndarray) – Decision matrix / alternatives data. Alternatives are in rows and Criteria are in columns.

Returns

Vector of weights.

Return type

ndarray