pymfe.relative.MFERelativeLandmarking
- class pymfe.relative.MFERelativeLandmarking[source]
Keep methods for metafeatures of
landmarkinggroup.The convention adopted for metafeature extraction related methods is to always start with
ft_prefix to allow automatic method detection. This prefix is predefined within_internalmodule.All method signature follows the conventions and restrictions listed below:
For independent attribute data,
Xmeansevery type of attribute,NmeansNumeric attributes onlyandCstands forCategorical attributes only. It is important to note that the categorical attribute sets betweenXandCand the numerical attribute sets betweenXandNmay differ due to data transformations, performed while fitting data into MFE model, enabled by, respectively,transform_numandtransform_catarguments fromfit(MFE method).Only arguments in MFE
_custom_args_ftattribute (set up insidefitmethod) are allowed to be required method arguments. All other arguments must be strictly optional (i.e., has a predefined default value).The initial assumption is that the user can change any optional argument, without any previous verification of argument value or its type, via kwargs argument of
extractmethod of MFE class.The return value of all feature extraction methods should be a single value or a generic List (preferably a
np.ndarray) type with numeric values.
There is another type of method adopted for automatic detection. It is adopted the prefix
precompute_for automatic detection of these methods. These methods run while fitting some data into an MFE model automatically, and their objective is to precompute some common value shared between more than one feature extraction method. This strategy is a trade-off between more system memory consumption and speeds up of feature extraction. Their return value must always be a dictionary whose keys are possible extra arguments for both feature extraction methods and other precomputation methods. Note that there is a share of precomputed values between all valid feature-extraction modules (e.g.,class_freqscomputed in modulestatisticalcan freely be used for any precomputation or feature extraction method of modulelandmarking).- __init__(*args, **kwargs)
Methods
__init__(*args, **kwargs)group_mtf_by_summary(mtf_names, mtf_vals, ...)Group metafeatures by its correspondent summary method.
postprocess_landmarking_relative(mtf_names, ...)Generate Relative Landmarking from Landmarking metafeatures.
- classmethod group_mtf_by_summary(mtf_names: List[str], mtf_vals: List[float], class_indexes: List[int]) Tuple[Dict[str, List[float]], Dict[str, List[int]]][source]
Group metafeatures by its correspondent summary method.
It is assumed that every distinct suffix after the first separator
.in the metafeature name corresponds to a different summary method, even if it is, for example, due to different bins of a histogram summarization.
- classmethod postprocess_landmarking_relative(mtf_names: List[str], mtf_vals: List[float], mtf_time: List[float], class_indexes: List[int], groups: Tuple[str, ...], inserted_group_dep: FrozenSet[str], **kwargs) Optional[Tuple[List[str], List[float], List[float]]][source]
Generate Relative Landmarking from Landmarking metafeatures.
- Parameters
- mtf_namesstr
Name of each generated metafeature (after extraction and summarization).
- mtf_valsstr
Value of each generated metafeature (after extraction and summarization).
- mtf_timestr
Time elapsed to generate each metafeature (after extraction and summarization).
- class_indexes
listof int List of indexes corresponding to metafeatures associated to metafeature groups present in this postprocessing method name (
LandmarkingandRelative.)- groups
tupleof str User-selected and automatic inserted (due to group dependencies) groups of metafeatures.
- inserted_group_dep
tupleof str Tuple with all automatic inserted metafeature groups due to dependency between groups.
- **kwargs: to keep consistency with the framework postprocessing
signature. Not used in this method.
- Returns
- If either
landmarkingorrelativeis not selected by the user - as a metafeature group:
Returns None.
- Else:
Returns three lists for generated relative landmarking metafeature names, values and time elapsed (in this order.)
- If either