September 2019
Intermediate to advanced
420 pages
10h 29m
English
The Pipeline class itself has a fit, a predict, and a score method, which all behave just like any other estimator in scikit-learn. The most common use case of the Pipeline class is to chain different preprocessing steps together with a supervised model like a classifier.
Let's return to the breast cancer dataset from Chapter 5, Using Decision Trees to Make a Medical Diagnosis. Using scikit-learn, we import the dataset and split it into training and test sets:
In [1]: from sklearn.datasets import load_breast_cancer... import numpy as np... cancer = load_breast_cancer()... X = cancer.data.astype(np.float32)... y = cancer.targetIn [2]: X_train, X_test, y_train, y_test = train_test_split(... X, y, random_state=37 ...
Read now
Unlock full access