Skip to content

ATOMModel


function atom.api.ATOMModel(estimator, name=None, acronym=None, needs_scaling=False, native_multilabel=False, native_multioutput=False, validation=None)[source]

Convert an estimator to a model that can be ingested by atom.

This function adds the relevant tags to the estimator so that they can be used by atom. Note that only estimators that follow sklearn's API are compatible.

Read more about custom models in the user guide.

Parameters estimator: Predictor
Custom estimator. Should implement a fit and predict method.

name: str or None, default=None
Name for the model. This is the value used to call the model from atom. The value should start with the model's acronym when specified. If None, the capital letters of the estimator's name are used (only if two or more, else it uses the entire name).

acronym: str or None, default=None
Model's acronym. If None, it uses the model's name. Specify this parameter when you want to train multiple custom models that share the same estimator.

needs_scaling: bool, default=False
Whether the model should use automated feature scaling.

native_multilabel: bool, default=False
Whether the model has native support for multilabel tasks. If False and the task is multilabel, a multilabel meta-estimator is wrapper around the estimator.

native_multioutput: bool, default=False
Whether the model has native support for multioutput tasks. If False and the task is multioutput, a multioutput meta-estimator is wrapped around the estimator.

validation: str or None, default=None
Whether the model allows in-training validation.

  • If None: No support for in-training validation.
  • If str: Name of the estimator's parameter that states the number of iterations, e.g., n_estimators for RandomForestClassifier.

Returns Predictor
Estimator with provided information. Provide this instance to the models parameter of the run method.

Example

>>> from atom import ATOMRegressor, ATOMModel
>>> from sklearn.datasets import load_diabetes
>>> from sklearn.linear_model import RANSACRegressor

>>> ransac = ATOMModel(
...     estimator=RANSACRegressor(),
...     name="RANSAC",
...     needs_scaling=False,
... )

>>> X, y = load_diabetes(return_X_y=True, as_frame=True)

>>> atom = ATOMRegressor(X, y, verbose=2)

<< ================== ATOM ================== >>

Configuration ==================== >>
Algorithm task: Regression.

Dataset stats ==================== >>
Shape: (442, 11)
Train set size: 354
Test set size: 88
-------------------------------------
Memory: 39.03 kB
Scaled: False
Outlier values: 8 (0.2%)

>>> atom.run(ransac)


Training ========================= >>
Models: RANSAC
Metric: r2


Results for RANSACRegressor:
Fit ---------------------------------------------
Train evaluation --> r2: 0.3461
Test evaluation --> r2: 0.2589
Time elapsed: 0.068s
-------------------------------------------------
Time: 0.068s


Final results ==================== >>
Total time: 0.069s
-------------------------------------
RANSACRegressor --> r2: 0.2589 ~