I want to apply sample weights and at the same time use a conveyor from sklearn, which should do a function conversion, for example. polynomial, and then apply a regressor, for example. ExtraTrees.
I use the following packages in the two examples below:
from sklearn.ensemble import ExtraTreesRegressor import numpy as np from sklearn.pipeline import Pipeline from sklearn.preprocessing import PolynomialFeatures
Everything works well, while I separately transform the functions, then create and equip the model:
#Feature generation X = np.random.rand(200,4) Y = np.random.rand(200)
But doing this in the pipeline does not work:
#Pipeline generation pipe = Pipeline([('poly2', PolynomialFeatures(degree=2)), ('ExtraTrees', ExtraTreesRegressor(n_estimators=5, max_depth = 3))])
I get the following error: TypeError: fit () takes no more than 3 arguments (4 data) In this simple example, I donβt need to change the code, but when I want to run several different tests on my real data in my real code, being able to use pipelines and sample weight
source share