Modules
- Alternative
- Compromise solutions
- Criteria
- Graphs
- Probabilistic
- Ranking
Results sensitivity assessment
- pysensmcda.calculate_preference.calculate_preference(func: callable, results: list | ndarray | tuple, method: callable, call_kwargs: dict, only_preference: bool = True, method_type: int | None = None) ndarray | tuple[source]
Wrapper for calculating preference depending on the sensitivity analysis function.
Parameters:
- func: callable
Function for pysensmcda library that was used to acquire results.
- results: depending on func
Results of the function which should be given as func.
- method: callable
Method that should be used to calculate preferences.
- call_kwargs: dict
Parameters that should be passed to method in order to calculate preferences. Used internally:
matrix for decision matrix weights for criteria weights
- only_preference: bool, optional, default=True
If True only preferences are returned in ndarray. If False list of tuples that resembles results is returned, where preferences are in the last column.
- method_type: int or None, optional, default=None
If set, rankings are returned. Supported values: -1 for ascending ranking; 1 for descending ranking
Returns:
- ndarray or list[tuple]
If only_preference=True, array of preferences calculated for different matrices / weights depending on the type of sensitivity analysis is returned. Else the preferences are appended to results as last column. If method_type is set, the rankings are appended to column after preferences.
Examples:
Example 1: Alternative sensitivity analysis - return only preferences
>>> from pymcdm.methods import TOPSIS >>> >>> topsis = TOPSIS() >>> >>> matrix = np.array([ >>> [4, 1, 6], >>> [2, 6, 3], >>> [9, 5, 7], >>> ]) >>> discrete_values = np.array([ >>> [[5, 6], [2, 4], [5, 8]], >>> [[3, 5.5], [4], [3.5, 4.5]], >>> [[7, 8], [6], [8, 9]], >>> ], dtype='object') >>> indexes = np.array([[0, 2], 1], dtype='object') >>> results = discrete_modification(matrix, discrete_values, indexes) >>> kwargs = { >>> 'matrix': matrix,, >>> 'weights': np.ones(matrix.shape[0])/matrix.shape[0], >>> 'types': np.ones(matrix.shape[0]) >>> } >>> >>> calculate_preference(discrete_modification, results, topsis, kwargs)
Example 2: Criteria sensitivity analysis - return preferences and rankings
>>> from pysensmcda.criteria import percentage_modification >>> >>> weights = np.array([0.3, 0.3, 0.4]) >>> percentage = 5 >>> results = percentage_modification(weights, percentage) >>> >>> kwargs = { >>> 'matrix': np.random.random((10, 3)), >>> 'weights': weights, >>> 'types': np.ones(3) >>> } >>> >>> calculate_preference(percentage_modification, results, topsis, kwargs, method_type=1)
Example 3: Criteria sensitivity analysis - return rankings and aggregated results
>>> from pysensmcda.criteria import percentage_modification >>> >>> weights = np.array([0.3, 0.3, 0.4]) >>> percentage = 5 >>> results = percentage_modification(weights, percentage) >>> >>> kwargs = { >>> 'matrix': np.random.random((10, 3)), >>> 'weights': weights, >>> 'types': np.ones(3) >>> } >>> >>> calculate_preference(percentage_modification, results, topsis, kwargs, only_preference=False, method_type=1)