Skip to content

score


method score(X, y, sample_weights=None, pipeline=None, verbose=None) [source]

Transform new data through all transformers in the current branch and return model's score. If called from a trainer, the best model in the pipeline (under the winner attribute) is used. If called from a model, that model is used. The estimator must have a score method.

Parameters:

X: dict, list, tuple, np.ndarray or pd.DataFrame
Feature set with shape=(n_samples, n_features).

y: int, str or sequence
  • If int: Position of the target column in X.
  • If str: Name of the target column in X.
  • Else: Target column with shape=(n_samples,).

sample_weights: sequence or None, optional (default=None)
Sample weights corresponding to y.

pipeline: bool, sequence or None, optional (default=None)
Transformers to use on the data before predicting.
  • If None: Only transformers that are applied on the whole dataset are used.
  • If False: Don't use any transformers.
  • If True: Use all transformers in the pipeline.
  • If sequence: Transformers to use, selected by their index in the pipeline.

verbose: int or None, optional (default=None)
Verbosity level of the output. If None, it uses the transformer's own verbosity.

Returns: score: np.float64
Mean accuracy or r2 (depending on the task) of predict(X) with respect to y.


Example

from atom import ATOMClassifier

atom = ATOMClassifier(X, y)
atom.run(["MNB", "KNN", "kSVM"], metric="precision")

# Get the mean accuracy on new data
predictions = atom.mnb.score(X_new, y_new)
Back to top