# Designing a training set for regression on probabiltiy values given time , categorical and continous features

Assume we have following variables out of which "Probability of sale " needs to be predicted , and this is to be done for a portable business vendor whose location changes with time :

Business street address|weather description | Day of Year | Day of Week | Hour of Day | Probability of sale

The above plot shows the average sales count along the time axis.

So how to design the training set for forecasting the sale probability in scikit learn such that it outputs a continous proabability range and thus help in the forecast or probability of sale prediction?

## 1 Answer

So in general your problem is how to use discrete features. There are many ways to do that, but here is what I would suggest as a first pass.

Convert each feature into boolean variables. For example $x_{Main}$ = 1 if street is Main and 0 otherwise and construct a variable like that for every street. The do the same for other variables. If you have a huge number of these new booleans you could eliminate the ones that have for example only a single 1 or only a few ones, or the ones that are all zeros etc...

Since you are saying you want to predict the probability of a sale you should use something like logistic regression. Use all these variables (as well as the numeric ones) as your regressors and put a penalty. You should read more about penalized regressions to make sure you know what you are doing but this could be a possible way to go.

Of course you could bundle some of these categories together, or figure out which streets are in one district and use district as a regressor etc. But if you have a lot of levels and a lot of data a penalized regression might be a good start.

• can the dictvctorizer be used instead of this dummy variable approach?, also how to put the penalty in scikitlearn? – stats101 Mar 26 '16 at 11:21
• also how to do regression giving output from 0-0.999 , what values to use in training? – stats101 Mar 26 '16 at 11:23
• updated the question – stats101 Mar 26 '16 at 11:26