简体   繁体   中英

Week Number in python for regression

My current data set is by Fiscal Week. It is in this format "FY2013 WK 2". How can I format it, so that I can use a regression model on it and predict a value for let's say "FY2017 WK 2".

Should I treat Fiscal Week as a categorical value and use dmatrices?

You will need to convert the string describing the week into an integer you can use as the abscissa (x-coordinate, or independent variable). Pick a "zero point", such as FY2012 WK 52 , so that FY2013 WK 01 translates to the integer 1.

I don't that DateTime handles this conversion; you might have to code the translation yourself: parse the string into year and week integers, and compute the abscissa from that:

52*(year-2013) + week

You might also want to keep a dictionary of those translations, as well as a reverse list (week => FY_week) for output labelling.

Does that move you toward a solution you can implement?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM