I am running randomforestregressor in python. The target variable I am modeling is the frequency of an event occurring per unit of time. Each record in my data includes whether or not the event occurred (0/1) and the amount of time the record spans (usually between 0 and 1 years). For various reasons, I need to assume that the frequency of occurrence per unit of time is constant for any length of time period so I want to use the time as a sample weight.
It is fairly clear in the rf.fit function in sklearn how to incorporate the sample weight (time) when building my randomforestregressormodel rf.fit(features,target,weight).
However, when I then apply my model to holdout test data, it isn't clear to me how or whether the predictions incorporate the weights for the prediction. The only inputs the prediction function accepts are: rf.predict(features) so it appears the predictions do not incorporate any sample weights.
It occurred to me to just multiply the test predictions from this function by the test weights, but the predictions before this adjustment are actually much closer to the correct test value than after multiplying by the test weights. The average test weight is about 0.50 and after multiplying the predictions by the test weight, my weighted test predictions were about 1/2 my actual test values which made me think I was double-counting the weight.
Does any one have any insight on how randomforestregressor uses sample weights in both fitting to training data and calculating predictions on test data?