batchflow.models¶
Contains models
- class BaseModel[source]¶
Base interface for models.
- property default_name¶
Placeholder for model name.
- class SklearnModel(*args, **kwargs)[source]¶
Base class for scikit-learn models
- estimator¶
an instance of scikit-learn estimator
Notes
Configuration
estimator - an instance of scikit-learn estimator
load / path - a path to a pickled estimator
Examples
pipeline .init_model('static', SklearnModel, 'my_model', config={'estimator': sklearn.linear_model.SGDClassifier(loss='huber')}) pipeline .init_model('static', SklearnModel, 'my_model', config={'load/path': '/path/to/estimator.pickle'})
- load(path)[source]¶
Load the model.
- Parameters
path (str) – a full path to a file from which a model will be loaded
- predict(x, *args, **kwargs)[source]¶
Predict with the data provided
- Parameters
X (array-like) – Subset of the training data, shape (n_samples, n_features)
Notes
For more details and other parameters look at the documentation for the estimator used.
- Returns
Predicted value per sample, shape (n_samples,)
- Return type
array
- save(path)[source]¶
Save the model.
- Parameters
path (str) – a full path to a file where a model will be saved to
- train(x, y, *args, **kwargs)[source]¶
Train the model with the data provided
- Parameters
X (array-like) – Subset of the training data, shape (n_samples, n_features)
y (numpy array) – Subset of the target values, shape (n_samples,)
Notes
For more details and other parameters look at the documentation for the estimator used.