I want to do cross-validation in sklearn like below, but the predicted result of X still need to be transformed to reduce the distance from y. How to do that with adding a custom function?
model = XGBRegressor(n_estimator = 500,
learn_rate = 0.05,
random_state = 0)
pipeline = Pipeline( steps = [('preprocessor', preprocessor),
('model', model)
])
scores = -1 * cross_val_score(pipeline, X, y,
cv = 3,
scoring = 'neg_mean_absolute_error',
verbose = 0)
There are only 0 and 1 in y, so I want to round and cut decimals off in the result of X, just after the step for predicting of X.
I maybe need other operations on y in the future. For example, fitting the correct result only includes the numbers like 0.5, 1.5, 2.5 ...
Example:
X - The input
ID Column_1 Column_2 Column_3
0 'A' 10 True
1 'A' 20 False
2 'B' 30 True
y - The correct result
ID Result
0 1
1 0
2 1
The current output
ID Result
0 0.899
1 -0.001
2 1.102
The expected output
ID Result
0 1
1 0
2 1
I have posted this question on Stack Overflow but also get no answers.
XGBClassifier
to automatically return binary values. $\endgroup$