Issue
I have a data set with policies that run for different numbers of days. The policies that run for more days have to have higher weight compared to the policies that run for less days. Is there a way that I can do that in tree based models in python? Especially, decision tree model.
Every policy is 1 row.
Thanks,
Solution
You can use the sample_weight
argument of the fit()
function to weight your training samples.
As follow:
from sklearn.tree import DecisionTreeClassifier
from sklearn.datasets import make_classification
X, y = make_classification()
weights = np.random.uniform(size=y.shape)
DecisionTreeClassifier().fit(X, y, sample_weight=weights)
Answered By - Antoine Dubuis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.