Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions docs/source/introduction/fedot_features/automation_features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ FEDOT supports bunch of dimensionality preprocessing operations that can be be a
`label_encoding`,Label Encoder, Feature encoding
`resample`,Imbalanced binary class transformation in classification, Data transformation
`topological_features`,Calculation of topological features,Time series transformation
`dummy`,Simple forwarding operator in pipeline, Data forwarding


.. csv-table:: Feature transformation operations implementations
:header: "API name","Model used","Presets"

`rfe_lin_reg`,`sklearn.feature_selection.RFE`,
`rfe_lin_reg`,`sklearn.feature_selection.RFE`,
`rfe_non_lin_reg`,`sklearn.feature_selection.RFE`,
`rfe_lin_class`,`sklearn.feature_selection.RFE`,
`rfe_non_lin_class`,`sklearn.feature_selection.RFE`,
Expand Down Expand Up @@ -107,13 +108,14 @@ FEDOT supports bunch of dimensionality preprocessing operations that can be be a
`resample`,`FEDOT model using sklearn.utils.resample`,
`topological_features`,FEDOT model,`ts`,
`fast_topological_features`,FEDOT model,`ts`
`dummy`,FEDOT model,`fast_train` `*tree`


Models used
^^^^^^^^^^^

Using the parameter ``preset`` of the :doc:`main API </api/api>` you can specify
what models are available during the learning process.
what models are available during the learning process.

It influences:

Expand All @@ -135,6 +137,7 @@ Apart from that there are other options whose names speak for themselves: ``'sta
:header: "API name","Definition","Problem"

`adareg`,AdaBoost regressor,Regression
`blendreg`, Weighted Average Blending,Regression
`catboostreg`,Catboost regressor,Regression
`dtreg`,Decision Tree regressor,Regression
`gbr`,Gradient Boosting regressor,Regression
Expand All @@ -149,6 +152,7 @@ Apart from that there are other options whose names speak for themselves: ``'sta
`treg`,Extra Trees regressor,Regression
`xgboostreg`,Extreme Gradient Boosting regressor,Regression
`bernb`,Naive Bayes classifier (multivariate Bernoulli),Classification
`blending`, Weighted Average Blending,Classification
`catboost`,Catboost classifier,Classification
`cnn`,Convolutional Neural Network,Classification
`dt`,Decision Tree classifier,Classification
Expand Down Expand Up @@ -179,6 +183,7 @@ Apart from that there are other options whose names speak for themselves: ``'sta
:header: "API name","Model used","Presets"

`adareg`,`sklearn.ensemble.AdaBoostRegressor`,`fast_train` `ts` `*tree`
`blendreg`, `FEDOT model`, `*tree`
`catboostreg`,`catboost.CatBoostRegressor`,`*tree`
`dtreg`,`sklearn.tree.DecisionTreeRegressor`,`fast_train` `ts` `*tree`
`gbr`,`sklearn.ensemble.GradientBoostingRegressor`,`*tree`
Expand All @@ -193,6 +198,7 @@ Apart from that there are other options whose names speak for themselves: ``'sta
`treg`,`sklearn.ensemble.ExtraTreesRegressor`,`*tree`
`xgboostreg`,`xgboost.XGBRegressor`,`*tree`
`bernb`,`sklearn.naive_bayes.BernoulliNB`,`fast_train`
`blending`, `FEDOT model`, `*tree`
`catboost`,`catboost.CatBoostClassifier`,`*tree`
`cnn`,`FEDOT model`,
`dt`,`sklearn.tree.DecisionTreeClassifier`,`fast_train` `*tree`
Expand Down
5 changes: 4 additions & 1 deletion fedot/api/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,13 @@ def setup_pipeline_structure(
- ``arima`` -> ARIMA
- ``cgru`` -> Convolutional Gated Recurrent Unit
- ``bernb`` -> Naive Bayes Classifier (multivariate Bernoulli)
- ``blending`` -> Weighted Average Blending Classifier
- ``blendreg`` -> Weighted Average Blending Regressor
- ``catboost`` -> Catboost Classifier
- ``catboostreg`` -> Catboost Regressor
- ``dt`` -> Decision Tree Classifier
- ``dtreg`` -> Decision Tree Regressor
- ``dummy`` -> Data Forwarding Operator in Pipeline
- ``gbr`` -> Gradient Boosting Regressor
- ``kmeans`` -> K-Means clustering
- ``knn`` -> K-nearest neighbors Classifier
Expand Down Expand Up @@ -305,7 +308,7 @@ def setup_pipeline_structure(
- ``svr`` -> Linear Support Vector Regressor
- ``treg`` -> Extra Trees Regressor
- ``xgboost`` -> Extreme Gradient Boosting Classifier
- ``xgbreg`` -> Extreme Gradient Boosting Regressor
- ``xgboostreg`` -> Extreme Gradient Boosting Regressor
- ``cnn`` -> Convolutional Neural Network
- ``scaling`` -> Scaling
- ``normalization`` -> Normalization
Expand Down
2 changes: 2 additions & 0 deletions fedot/core/operations/evaluation/boostings.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def predict(self, trained_operation, predict_data: InputData) -> OutputData:
is_multi_output_target = is_multi_output_task(predict_data)

prediction = trained_operation.predict_proba(predict_data)
if isinstance(prediction, OutputData):
prediction = prediction.predict
is_prediction_correct = self._check_prediction_correctness(prediction)

if n_classes < 2:
Expand Down
6 changes: 5 additions & 1 deletion fedot/core/operations/evaluation/common_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from fedot.core.operations.evaluation.operation_implementations. \
data_operations.topological.fast_topological_extractor import \
TopologicalFeaturesImplementation
from fedot.core.operations.evaluation.operation_implementations.data_operations.dummy import \
DummyOperationImplementation
from fedot.core.operations.operation_parameters import OperationParameters
from fedot.utilities.random import ImplementationRandomStateHandler

Expand All @@ -34,6 +36,7 @@ class FedotPreprocessingStrategy(EvaluationStrategy):
- ``one_hot_encoding``-> OneHotEncodingImplementation,
- ``label_encoding``-> LabelEncodingImplementation,
- ``fast_ica``-> FastICAImplementation
- ``dummy`` -> DummyOperationImplementation

params: hyperparameters to fit the operation with

Expand All @@ -50,7 +53,8 @@ class FedotPreprocessingStrategy(EvaluationStrategy):
'one_hot_encoding': OneHotEncodingImplementation,
'label_encoding': LabelEncodingImplementation,
'fast_ica': FastICAImplementation,
'topological_features': TopologicalFeaturesImplementation
'topological_features': TopologicalFeaturesImplementation,
'dummy': DummyOperationImplementation
}

def __init__(self, operation_type: str, params: Optional[OperationParameters] = None):
Expand Down
89 changes: 89 additions & 0 deletions fedot/core/operations/evaluation/ensemble.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import numpy as np
from typing import Optional
from abc import abstractmethod

from fedot.core.data.data import InputData, OutputData
from fedot.core.operations.evaluation.operation_implementations.models.blending import (
BlendingClassifier, BlendingRegressor
)
from fedot.core.operations.evaluation.evaluation_interfaces import EvaluationStrategy
from fedot.core.operations.operation_parameters import OperationParameters
from fedot.core.operations.evaluation.evaluation_interfaces import is_multi_output_task
from fedot.utilities.custom_errors import AbstractMethodNotImplementError
from fedot.utilities.random import ImplementationRandomStateHandler


class EnsembleStrategy(EvaluationStrategy):
"""This class defines the certain operation implementation for the ensemble methods

Args:
operation_type: ``str`` of the operation defined in operation or
data operation repositories

.. details:: possible operations:

- ``blending`` -> BlendingClassifier
- ``blendreg`` -> BlendingRegressor

params: hyperparameters to fit the operation with
"""
_operations_by_types = {
'blending': BlendingClassifier,
'blendreg': BlendingRegressor
}

def __init__(self, operation_type: str, params: Optional[OperationParameters] = None):
self.operation_impl = self._convert_to_operation(operation_type)
super().__init__(operation_type, params)

def fit(self, train_data: InputData):
if is_multi_output_task(train_data):
raise ValueError('Ensemble methods temporary do not support multi-output tasks.')

operation_implementation = self.operation_impl(self.params_for_fit)

with ImplementationRandomStateHandler(implementation=operation_implementation):
operation_implementation.fit(train_data)

return operation_implementation

@abstractmethod
def predict(self, trained_operation, predict_data: InputData) -> OutputData:
"""This method used for prediction of the target data

Args:
trained_operation: operation object
predict_data: data to predict

Returns:
passed data with new predicted target
"""
raise AbstractMethodNotImplementError


class EnsembleClassificationStrategy(EnsembleStrategy):
def __init__(self, operation_type: str, params: Optional[OperationParameters] = None):
super().__init__(operation_type, params)

def predict(self, trained_operation, predict_data: InputData) -> OutputData:
if self.output_mode == 'labels':
prediction = trained_operation.predict(predict_data)
elif self.output_mode in ['probs', 'full_probs', 'default']:
n_classes = len(trained_operation.classes_)
prediction = trained_operation.predict_proba(predict_data).predict
# Full probs for binary classification
if self.output_mode == 'full_probs' and n_classes == 2 and prediction.shape[1] == 1:
prediction = np.hstack([1 - prediction, prediction])
else:
raise ValueError(f'Output mode {self.output_mode} is not supported')

return self._convert_to_output(prediction, predict_data)


class EnsembleRegressionStrategy(EnsembleStrategy):
def __init__(self, operation_type: str, params: Optional[OperationParameters] = None):
super().__init__(operation_type, params)

def predict(self, trained_operation, predict_data: InputData, **kwargs) -> OutputData:
prediction = trained_operation.predict(predict_data, **kwargs)
return self._convert_to_output(prediction, predict_data)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from typing import Optional

from fedot.core.data.data import InputData, OutputData
from fedot.core.operations.evaluation.operation_implementations. \
implementation_interfaces import DataOperationImplementation
from fedot.core.operations.operation_parameters import OperationParameters


class DummyOperationImplementation(DataOperationImplementation):
""" Dummy class for data forwarding """

def __init__(self, params: Optional[OperationParameters]):
super().__init__(params)

def fit(self, input_data: InputData):
"""
Dummy operation doesn't support fit method
"""
pass

def transform(self, input_data: InputData) -> OutputData:
"""
Method for forwarding input_data's features
:param input_data: data with features, target and ids

:return input_data: data with the same features
"""
features = input_data.features
output_data = self._convert_to_output(input_data, features)
return output_data
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def fit(self, input_data: InputData):
self.operation.fit(input_data.features, input_data.target)
return self.operation
except ValueError:
self.log.info("RANSAC: multiplied residual_threshold on 2")
self.log.debug("RANSAC: multiplied residual_threshold on 2")
residual_threshold = residual_threshold * 2
iter_ += 1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import logging
from itertools import chain
from typing import Optional
Expand All @@ -7,9 +8,12 @@
try:
from gph import ripser_parallel as ripser
except ModuleNotFoundError:
logging.log(100,
"Topological features operation requires extra dependencies for time series forecasting, which are not"
" installed. It can infuence the performance. Please install it by 'pip install fedot[extra]'")
if not os.environ.get('FEDOT_RIPSER_WARNING_SHOWN'):
logging.log(100,
"Topological features operation requires extra dependencies for time series forecasting, "
"which are not installed. It can influence the performance. "
"Please install it by 'pip install fedot[extra]'")
os.environ['FEDOT_RIPSER_WARNING_SHOWN'] = '1'

from joblib import Parallel, delayed

Expand Down
Loading