SciPy - Integration with Scientific Ecosystem
Consider the pipeline below. What will
pipe.predict([[3]]) return?from sklearn.pipeline import Pipeline
from sklearn.preprocessing import FunctionTransformer
from sklearn.linear_model import LinearRegression
import numpy as np
def cube(x):
return x ** 3
pipe = Pipeline([
('cube', FunctionTransformer(cube)),
('lr', LinearRegression())
])
X_train = np.array([[1], [2], [3], [4]])
y_train = np.array([1, 8, 27, 64])
pipe.fit(X_train, y_train)
print(pipe.predict([[3]]))