1
$\begingroup$

I have a data set with the variables: y,n,date,x1,x2,x3. I'm trying to predict y through x1,x2,x3 - categorical variables. I'm building a linear regression model in python. I'm interested in using weights:

  • n - number of observation per row
  • date - give more weight to more recent data (will use some power function here)

I know how to use regression with one variable that represent weight:

regr = linear_model.LinearRegression()
model1=regr.fit(X, y,sample_weight=n)

My question is- does it make sense to use two weighting variables (n,date) ? and how can I do it in python ?

Thanks

$\endgroup$
  • $\begingroup$ I think you mean "does it make sense ..." rather than does it make since...". $\endgroup$ – Michael Chernick Apr 23 '17 at 11:26
  • $\begingroup$ The conceptual part of your question may well be answered on this site. The python part would need to be asked elsewhere. $\endgroup$ – rolando2 Apr 23 '17 at 12:08
  • $\begingroup$ To my understanding, weight should be the inverse of variance. $\endgroup$ – SmallChess Apr 23 '17 at 12:18
  • $\begingroup$ You cannot use different weights for different variables in sklearn. $\endgroup$ – DYZ Apr 24 '17 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.