mlinsights icon indicating copy to clipboard operation
mlinsights copied to clipboard

Sample weights for PiecewiseTreeRegressor

Open jakebasilico opened this issue 2 years ago • 3 comments

I'm trying to build an ensemble learner using PiecewiseTreeRegressors. In doing so, the parameter "sample_weight" is utilized during fitting of the estimator. This throws an error here: https://github.com/sdpython/mlinsights/blob/c23988e57080058686418d9e22401d39865c97ff/mlinsights/mlmodel/piecewise_tree_regression_criterion_linear.pyx#L150

when executing line 136 in piecewise_tree_regression.py: https://github.com/sdpython/mlinsights/blob/c23988e57080058686418d9e22401d39865c97ff/mlinsights/mlmodel/piecewise_tree_regression.py#L136

AttributeError: 'mlinsights.mlmodel.piecewise_tree_regression_crite' object has no attribute 'sum'

jakebasilico avatar Aug 30 '22 21:08 jakebasilico

Also an error here when checking whether sample_weight is none: https://github.com/sdpython/mlinsights/blob/c23988e57080058686418d9e22401d39865c97ff/mlinsights/mlmodel/piecewise_tree_regression.py#L135

Because sample_weight is an numpy array, it looks like using sample_weight.any() or "if sample_weight is not None" fixes this issue

jakebasilico avatar Aug 30 '22 21:08 jakebasilico

Loving the package so far!

jakebasilico avatar Aug 30 '22 21:08 jakebasilico

Sorry for the delay, is it possible to know how you call it? sample_weights should be an array.

sdpython avatar Nov 11 '22 13:11 sdpython