FEDOT API¶
-
class
fedot.api.main.
Fedot
(problem, preset=None, timeout=5.0, composer_params=None, task_params=None, seed=None, verbose_level=0, safe_mode=True, initial_assumption=None, n_jobs=1, use_cache=False)¶ Bases:
object
Main class for FEDOT API. Facade for ApiDataProcessor, ApiComposer, ApiMetrics, ApiInitialAssumptions. :param problem: the name of modelling problem to solve:
classification
regression
ts_forecasting
clustering
- Parameters
preset (str) –
name of preset for model building (e.g. ‘best_quality’, ‘fast_train’, ‘gpu’) - ‘best_quality’ - All models that are available for this data type and task are used - ‘fast_train’ - Models that learn quickly. This includes preprocessing operations
- (data operations) that only reduce the dimensionality of the data, but cannot increase
it. For example, there are no polynomial features and one-hot encoding operations
’stable’ - The most reliable preset in which the most stable operations are included.
’auto’ - Automatically determine which preset should be used.
’gpu’ - Models that use GPU resources for computation.
’ts’ - A special preset with models for time series forecasting task.
’automl’ - A special preset with only AutoML libraries such as TPOT and H2O as operations.
’*tree’ - A special preset that allows only tree-based algorithms
timeout (Optional[float]) – time for model design (in minutes) - None or -1 means infinite time
composer_params (dict) –
parameters of pipeline optimisation The possible parameters are:
’max_depth’ - max depth of the pipeline ‘max_arity’ - max arity of the pipeline nodes ‘pop_size’ - population size for composer ‘num_of_generations’ - number of generations for composer ‘available_operations’ - list of model names to use ‘with_tuning’ - allow hyperparameters tuning for the model ‘cv_folds’ - number of folds for cross-validation ‘validation_blocks’ - number of validation blocks for time series forecasting ‘initial_assumption’ - initial assumption for composer ‘genetic_scheme’ - name of the genetic scheme ‘history_folder’ - name of the folder for composing history ‘metric’ - metric for quality calculation during composing ‘collect_intermediate_metric’ - save metrics for intermediate (non-root) nodes in pipeline
task_params (fedot.core.repository.tasks.TaskParams) – additional parameters of the task
seed – value for fixed random seed
verbose_level (int) – level of the output detailing (-1 - nothing, 0 - errors, 1 - messages, 2 - warnings and info, 3-4 - basic and detailed debug)
safe_mode – if set True it will cut large datasets to prevent memory overflow and use label encoder
problem (str) –
List[fedot.core.pipelines.pipeline.Pipeline]] initial_assumption (Union[fedot.core.pipelines.pipeline.Pipeline,) –
n_jobs (int) –
use_cache (bool) –
instead of oneHot encoder if summary cardinality of categorical features is high. :param initial_assumption: initial assumption for composer :param n_jobs: num of n_jobs for parallelization (-1 for use all cpu’s) :param use_cache: bool indicating if it is needed to use pipeline structures caching
-
fit
(features, target='target', predefined_model=None)¶ Fit the graph with a predefined structure or compose and fit the new graph :param features: the array with features of train data :param target: the array with target values of train data :param predefined_model: the name of the atomic model or Pipeline instance. If argument is ‘auto’, perform initial assumption generation and then fit the pipeline :return: Pipeline object
- Parameters
numpy.ndarray, pandas.core.frame.DataFrame, fedot.core.data.data.InputData, dict] features (Union[str,) –
numpy.ndarray, pandas.core.series.Series, dict] target (Union[str,) –
fedot.core.pipelines.pipeline.Pipeline] predefined_model (Union[str,) –
- Return type
-
predict
(features, save_predictions=False)¶ Predict new target using already fitted model :param features: the array with features of test data :param save_predictions: if True-save predictions as csv-file in working directory. :return: the array with prediction values
- Parameters
numpy.ndarray, pandas.core.frame.DataFrame, fedot.core.data.data.InputData, dict] features (Union[str,) –
save_predictions (bool) –
- Return type
numpy.ndarray
-
predict_proba
(features, save_predictions=False, probs_for_all_classes=False)¶ Predict the probability of new target using already fitted classification model :param features: the array with features of test data :param save_predictions: if True-save predictions as csv-file in working directory. :param probs_for_all_classes: return probability for each class even for binary case :return: the array with prediction values
- Parameters
numpy.ndarray, pandas.core.frame.DataFrame, fedot.core.data.data.InputData, dict] features (Union[str,) –
save_predictions (bool) –
probs_for_all_classes (bool) –
- Return type
numpy.ndarray
-
forecast
(pre_history, forecast_length=1, save_predictions=False)¶ Forecast the new values of time series :param pre_history: the array with features for pre-history of the forecast :param forecast_length: num of steps to forecast :param save_predictions: if True-save predictions as csv-file in working directory. :return: the array with prediction values
- Parameters
Tuple[numpy.ndarray, numpy.ndarray], fedot.core.data.data.InputData, dict] pre_history (Union[str,) –
forecast_length (int) –
save_predictions (bool) –
- Return type
numpy.ndarray
-
load
(path)¶ Load saved graph from disk :param path to json file with model
-
plot_pareto
()¶
-
plot_prediction
(target=None)¶ Plot the prediction obtained from graph :param target: user-specified name of target variable for MultiModalData
- Parameters
target ([typing.Optional]) –
-
get_metrics
(target=None, metric_names=None)¶ Get quality metrics for the fitted graph :param target: the array with target values of test data :param metric_names: the names of required metrics :return: the values of quality metrics
- Parameters
pandas.core.series.Series] target (Union[numpy.ndarray,) –
List[str]] metric_names (Union[str,) –
- Return type
dict
-
save_predict
(predicted_data)¶ Save pipeline forecasts in csv file
- Parameters
predicted_data (fedot.core.data.data.OutputData) –
-
export_as_project
(project_path='fedot_project.zip')¶
-
import_as_project
(project_path='fedot_project.zip')¶
-
update_params
(timeout, num_of_generations, initial_assumption)¶
-
explain
(features=None, method='surrogate_dt', visualize=True, **kwargs)¶ Create explanation for ‘current_pipeline’ according to the selected ‘method’. An Explainer instance is returned. :param features: samples to be explained. If None, train_data from last fit is used. :param method: explanation method, defaults to ‘surrogate_dt’. Options: [‘surrogate_dt’, …] :param visualize: print and plot the explanation simultaneously, defaults to True.
The explanation can be retrieved later by executing explainer.visualize().
- Parameters
numpy.ndarray, pandas.core.frame.DataFrame, fedot.core.data.data.InputData, dict] features (Union[str,) –
method (str) –
visualize (bool) –
- Return type
fedot.explainability.explainer_template.Explainer