skcriteria.preprocessing.filters
module¶
Normalization through the distance to distance function.
- class skcriteria.preprocessing.filters.SKCByCriteriaFilterABC(criteria_filters, *, ignore_missing_criteria=False)[source]¶
Bases:
SKCTransformerABC
Abstract class capable of filtering alternatives based on criteria values.
This abstract class require to redefine
_coerce_filters
and_make_mask
, instead of_transform_data
.- Parameters:
- property criteria_filters¶
Conditions on which the alternatives will be evaluated.
It is a dictionary in which the key is the name of a criterion, and the value is the filter condition.
- property ignore_missing_criteria¶
If the value is True the filter ignores the lack of a required criterion.
If the value is False, the lack of a criterion causes the filter to fail.
- class skcriteria.preprocessing.filters.Filter(criteria_filters, *, ignore_missing_criteria=False)[source]¶
Bases:
SKCByCriteriaFilterABC
Function based filter.
This class accepts as a filter any arbitrary function that receives as a parameter a as a parameter a criterion and returns a mask of the same size as the number of the number of alternatives in the decision matrix.
- Parameters:
Examples
>>> from skcriteria.preprocess import filters >>> dm = skc.mkdm( ... matrix=[ ... [7, 5, 35], ... [5, 4, 26], ... [5, 6, 28], ... [1, 7, 30], ... [5, 8, 30] ... ], ... objectives=[max, max, min], ... alternatives=["PE", "JN", "AA", "MM", "FN"], ... criteria=["ROE", "CAP", "RI"], ... ) >>> tfm = filters.Filter({ ... "ROE": lambda e: e > 1, ... "RI": lambda e: e >= 28, ... }) >>> tfm.transform(dm) ROE[▲ 2.0] CAP[▲ 4.0] RI[▼ 1.0] PE 7 5 35 AA 5 6 28 FN 5 8 30 [3 Alternatives x 3 Criteria]
- class skcriteria.preprocessing.filters.SKCArithmeticFilterABC(criteria_filters, *, ignore_missing_criteria=False)[source]¶
Bases:
SKCByCriteriaFilterABC
Provide a common behavior to make filters based on the same comparator.
This abstract class require to redefine
_filter
method, and this will apply to each criteria separately.This class is designed to implement in general arithmetic comparisons of “==”, “!=”, “>”, “>=”, “<”, “<=” taking advantage of the functions provided by numpy (e.g.
np.greater_equal()
).- Parameters:
Notes
The filter implemented with this class are slightly faster than function-based filters.
- class skcriteria.preprocessing.filters.FilterGT(criteria_filters, *, ignore_missing_criteria=False)[source]¶
Bases:
SKCArithmeticFilterABC
Keeps the alternatives for which the criteria value are greater than a value.
- Parameters:
Notes
The filter implemented with this class are slightly faster than function-based filters.
Examples
>>> from skcriteria.preprocess import filters >>> dm = skc.mkdm( ... matrix=[ ... [7, 5, 35], ... [5, 4, 26], ... [5, 6, 28], ... [1, 7, 30], ... [5, 8, 30] ... ], ... objectives=[max, max, min], ... alternatives=["PE", "JN", "AA", "MM", "FN"], ... criteria=["ROE", "CAP", "RI"], ... ) >>> tfm = filters.FilterGT({"ROE": 1, "RI": 27}) >>> tfm.transform(dm) ROE[▲ 2.0] CAP[▲ 4.0] RI[▼ 1.0] PE 7 5 35 AA 5 6 28 FN 5 8 30 [3 Alternatives x 3 Criteria]
- class skcriteria.preprocessing.filters.FilterGE(criteria_filters, *, ignore_missing_criteria=False)[source]¶
Bases:
SKCArithmeticFilterABC
Keeps the alternatives for which the criteria value are greater or equal than a value.
- Parameters:
Notes
The filter implemented with this class are slightly faster than function-based filters.
Examples
>>> from skcriteria.preprocess import filters >>> dm = skc.mkdm( ... matrix=[ ... [7, 5, 35], ... [5, 4, 26], ... [5, 6, 28], ... [1, 7, 30], ... [5, 8, 30] ... ], ... objectives=[max, max, min], ... alternatives=["PE", "JN", "AA", "MM", "FN"], ... criteria=["ROE", "CAP", "RI"], ... ) >>> tfm = filters.FilterGE({"ROE": 1, "RI": 27}) >>> tfm.transform(dm) ROE[▲ 2.0] CAP[▲ 4.0] RI[▼ 1.0] PE 7 5 35 AA 5 6 28 MM 1 7 30 FN 5 8 30 [4 Alternatives x 3 Criteria]
- class skcriteria.preprocessing.filters.FilterLT(criteria_filters, *, ignore_missing_criteria=False)[source]¶
Bases:
SKCArithmeticFilterABC
Keeps the alternatives for which the criteria value are less than a value.
- Parameters:
Notes
The filter implemented with this class are slightly faster than function-based filters.
Examples
>>> from skcriteria.preprocess import filters >>> dm = skc.mkdm( ... matrix=[ ... [7, 5, 35], ... [5, 4, 26], ... [5, 6, 28], ... [1, 7, 30], ... [5, 8, 30] ... ], ... objectives=[max, max, min], ... alternatives=["PE", "JN", "AA", "MM", "FN"], ... criteria=["ROE", "CAP", "RI"], ... ) >>> tfm = filters.FilterLT({"RI": 28}) >>> tfm.transform(dm) ROE[▲ 2.0] CAP[▲ 4.0] RI[▼ 1.0] JN 5 4 26 [1 Alternatives x 3 Criteria]
- class skcriteria.preprocessing.filters.FilterLE(criteria_filters, *, ignore_missing_criteria=False)[source]¶
Bases:
SKCArithmeticFilterABC
Keeps the alternatives for which the criteria value are less or equal than a value.
- Parameters:
Notes
The filter implemented with this class are slightly faster than function-based filters.
Examples
>>> from skcriteria.preprocess import filters >>> dm = skc.mkdm( ... matrix=[ ... [7, 5, 35], ... [5, 4, 26], ... [5, 6, 28], ... [1, 7, 30], ... [5, 8, 30] ... ], ... objectives=[max, max, min], ... alternatives=["PE", "JN", "AA", "MM", "FN"], ... criteria=["ROE", "CAP", "RI"], ... ) >>> tfm = filters.FilterLE({"RI": 28}) >>> tfm.transform(dm) ROE[▲ 2.0] CAP[▲ 4.0] RI[▼ 1.0] JN 5 4 26 AA 5 6 28 [2 Alternatives x 3 Criteria]
- class skcriteria.preprocessing.filters.FilterEQ(criteria_filters, *, ignore_missing_criteria=False)[source]¶
Bases:
SKCArithmeticFilterABC
Keeps the alternatives for which the criteria value are equal than a value.
- Parameters:
Notes
The filter implemented with this class are slightly faster than function-based filters.
Examples
>>> from skcriteria.preprocess import filters >>> dm = skc.mkdm( ... matrix=[ ... [7, 5, 35], ... [5, 4, 26], ... [5, 6, 28], ... [1, 7, 30], ... [5, 8, 30] ... ], ... objectives=[max, max, min], ... alternatives=["PE", "JN", "AA", "MM", "FN"], ... criteria=["ROE", "CAP", "RI"], ... ) >>> tfm = filters.FilterEQ({"CAP": 7, "RI": 30}) >>> tfm.transform(dm) ROE[▲ 2.0] CAP[▲ 4.0] RI[▼ 1.0] MM 1 7 30 [1 Alternatives x 3 Criteria]
- class skcriteria.preprocessing.filters.FilterNE(criteria_filters, *, ignore_missing_criteria=False)[source]¶
Bases:
SKCArithmeticFilterABC
Keeps the alternatives for which the criteria value are not equal than a value.
- Parameters:
Notes
The filter implemented with this class are slightly faster than function-based filters.
Examples
>>> from skcriteria.preprocess import filters >>> dm = skc.mkdm( ... matrix=[ ... [7, 5, 35], ... [5, 4, 26], ... [5, 6, 28], ... [1, 7, 30], ... [5, 8, 30] ... ], ... objectives=[max, max, min], ... alternatives=["PE", "JN", "AA", "MM", "FN"], ... criteria=["ROE", "CAP", "RI"], ... ) >>> tfm = filters.FilterNE({"CAP": 7, "RI": 30}) >>> tfm.transform(dm) ROE[▲ 2.0] CAP[▲ 4.0] RI[▼ 1.0] PE 7 5 35 JN 5 4 26 AA 5 6 28 [3 Alternatives x 3 Criteria]
- class skcriteria.preprocessing.filters.SKCSetFilterABC(criteria_filters, *, ignore_missing_criteria=False)[source]¶
Bases:
SKCByCriteriaFilterABC
Provide a common behavior to make filters based on set operations.
This abstract class require to redefine
_set_filter
method, and this will apply to each criteria separately.This class is designed to implement in general set comparison like “inclusion” and “exclusion”.
- class skcriteria.preprocessing.filters.FilterIn(criteria_filters, *, ignore_missing_criteria=False)[source]¶
Bases:
SKCSetFilterABC
Keeps the alternatives for which the criteria value are included in a set of values.
- Parameters:
Examples
>>> from skcriteria.preprocess import filters >>> dm = skc.mkdm( ... matrix=[ ... [7, 5, 35], ... [5, 4, 26], ... [5, 6, 28], ... [1, 7, 30], ... [5, 8, 30] ... ], ... objectives=[max, max, min], ... alternatives=["PE", "JN", "AA", "MM", "FN"], ... criteria=["ROE", "CAP", "RI"], ... ) >>> tfm = filters.FilterIn({"ROE": [7, 1], "RI": [30, 35]}) >>> tfm.transform(dm) ROE[▲ 2.0] CAP[▲ 4.0] RI[▼ 1.0] PE 7 5 35 MM 1 7 30 [2 Alternatives x 3 Criteria]
- class skcriteria.preprocessing.filters.FilterNotIn(criteria_filters, *, ignore_missing_criteria=False)[source]¶
Bases:
SKCSetFilterABC
Keeps the alternatives for which the criteria value are not included in a set of values.
- Parameters:
Examples
>>> from skcriteria.preprocess import filters >>> dm = skc.mkdm( ... matrix=[ ... [7, 5, 35], ... [5, 4, 26], ... [5, 6, 28], ... [1, 7, 30], ... [5, 8, 30] ... ], ... objectives=[max, max, min], ... alternatives=["PE", "JN", "AA", "MM", "FN"], ... criteria=["ROE", "CAP", "RI"], ... ) >>> tfm = filters.FilterNotIn({"ROE": [7, 1], "RI": [30, 35]}) >>> tfm.transform(dm) ROE[▲ 2.0] CAP[▲ 4.0] RI[▼ 1.0] JN 5 4 26 AA 5 6 28 [2 Alternatives x 3 Criteria]
- class skcriteria.preprocessing.filters.FilterNonDominated(*, strict=False)[source]¶
Bases:
SKCTransformerABC
Keeps the non dominated or non strictly-dominated alternatives.
In order to evaluate the dominance of an alternative a0 over an alternative a1, the algorithm evaluates that a0 is better in at least one criterion and that a1 is not better in any criterion than a0. In the case that
strict = True
it also evaluates that there are no equal criteria.- Parameters:
strict (bool, default
False
) – IfTrue
, strictly dominated alternatives are removed, otherwise all dominated alternatives are removed.
Examples
>>> from skcriteria.preprocess import filters >>> dm = skc.mkdm( ... matrix=[ ... [7, 5, 35], ... [5, 4, 26], ... [5, 6, 28], ... [1, 7, 30], ... [5, 8, 30] ... ], ... objectives=[max, max, min], ... alternatives=["PE", "JN", "AA", "MM", "FN"], ... criteria=["ROE", "CAP", "RI"], ... ) >>> tfm = filters.FilterNonDominated(strict=False) >>> tfm.transform(dm) ROE[▲ 1.0] CAP[▲ 1.0] RI[▼ 1.0] PE 7 5 35 JN 5 4 26 AA 5 6 28 FN 5 8 30 [4 Alternatives x 3 Criteria]
- property strict¶
If the filter must remove the dominated or strictly-dominated alternatives.