Unsupervised learning¶
This module contains the base class for the unsupervised machine learning algorithms.
The unsupervised
module implements
the concept of unsupervised machine learning models,
where the data has no notion of input or output.
This concept is implemented through the MLUnsupervisedAlgo
class,
which inherits from the MLAlgo
class.
Classes:
|
Unsupervised machine learning algorithm. |
- class gemseo.mlearning.core.unsupervised.MLUnsupervisedAlgo(data, transformer=None, var_names=None, **parameters)[source]
Unsupervised machine learning algorithm.
Inheriting classes shall overload the
MLUnsupervisedAlgo._fit()
method.- Attributes
learning_set (Dataset) – The learning dataset.
parameters (Dict[str,MLAlgoParameterType]) – The parameters of the machine learning algorithm.
transformer (Dict[str,Transformer]) – The strategies to transform the variables. The values are instances of
Transformer
while the keys are the names of either the variables or the groups of variables, e.g. “inputs” or “outputs” in the case of the regression algorithms. If a group is specified, theTransformer
will be applied to all the variables of this group. If None, do not transform the variables.algo (Any) – The interfaced machine learning algorithm.
input_names (List[str]) – The names of the variables.
- Parameters
data (Dataset) –
transformer (Optional[TransformerType]) –
var_names (Optional[Iterable[str]]) –
parameters (MLAlgoParameterType) –
- Return type
None
Parameters: data: The learning dataset. transformer: The strategies to transform the variables.
The values are instances of
Transformer
while the keys are the names of either the variables or the groups of variables, e.g. “inputs” or “outputs” in the case of the regression algorithms. If a group is specified, theTransformer
will be applied to all the variables of this group. If None, do not transform the variables.**parameters: The parameters of the machine learning algorithm. var_names: The names of the variables.
If None, consider all variables mentioned in the learning dataset.
Classes:
Decorators for the internal MLAlgo methods.
Attributes:
Return whether the algorithm is trained.
Methods:
learn
([samples])Train the machine learning algorithm from the learning dataset.
load_algo
(directory)Load a machine learning algorithm from a directory.
save
([directory, path, save_learning_set])Save the machine learning algorithm.
- class DataFormatters
Decorators for the internal MLAlgo methods.
- property is_trained
Return whether the algorithm is trained.
- learn(samples=None)[source]
Train the machine learning algorithm from the learning dataset.
- Parameters
samples (Optional[List[int]]) – The indices of the learning samples. If None, use the whole learning dataset.
- Return type
None
- load_algo(directory)
Load a machine learning algorithm from a directory.
- Parameters
directory (str) – The path to the directory where the machine learning algorithm is saved.
- Return type
None
- save(directory=None, path='.', save_learning_set=False)
Save the machine learning algorithm.
- Parameters
directory (Optional[str]) – The name of the directory to save the algorithm.
path (str) – The path to parent directory where to create the directory.
save_learning_set (bool) – If False, do not save the learning set to lighten the saved files.
- Returns
The path to the directory where the algorithm is saved.
- Return type
str