Jan-11-2020, 12:27 PM
Hi guys,
I am currently working on a regression task with python. My model contains 26 variables, 17 of them are dummy variables.
With that model I am trying to predict the dependent variable based on a MANUALLY inserted information. In other words I need a list which contains values for 26 variables so that the prediction can work. My problem is that I can't find an easy way to deal with the dummy variables.
My first bit of code looks like this and affects the non-dummy variables. I am ignoring syntax for now.
test = []
features1 = [ variable1, variable2, variable3, variable4, variable5, variable6, variable7, variable8, variable9 ]
for i in features1:
p = input('Enter: ' + str(i) + ' ' )
test.append(p)
this gives me a list something like this : test = [1, 2, 3, 4, 5, 6, 7, 8, 9]
The next 17 values can only be 0 or 1, since those are 2 dummy variables. So to be more precise , it has two ones and the rest are zeros.
Lets say for example the first dummy variable is about the weather. So it can be either :
sunny, cloudy, rainy, windy and foggy. If its cloudy the list would look like this : test = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 0, 0, 0]
If its foggy it would look like this test = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 1]
I would love to simply put in either weather condition and based on the input append the list accordingly.
E.g. the input would be : cloudy, and the code adds 0 , 1, 0, 0, 0 to the list. However I have no clue how this can be done with minimal amount of code. I am very thankful for any help and hope my question is clear!
I am currently working on a regression task with python. My model contains 26 variables, 17 of them are dummy variables.
With that model I am trying to predict the dependent variable based on a MANUALLY inserted information. In other words I need a list which contains values for 26 variables so that the prediction can work. My problem is that I can't find an easy way to deal with the dummy variables.
My first bit of code looks like this and affects the non-dummy variables. I am ignoring syntax for now.
test = []
features1 = [ variable1, variable2, variable3, variable4, variable5, variable6, variable7, variable8, variable9 ]
for i in features1:
p = input('Enter: ' + str(i) + ' ' )
test.append(p)
this gives me a list something like this : test = [1, 2, 3, 4, 5, 6, 7, 8, 9]
The next 17 values can only be 0 or 1, since those are 2 dummy variables. So to be more precise , it has two ones and the rest are zeros.
Lets say for example the first dummy variable is about the weather. So it can be either :
sunny, cloudy, rainy, windy and foggy. If its cloudy the list would look like this : test = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 0, 0, 0]
If its foggy it would look like this test = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 1]
I would love to simply put in either weather condition and based on the input append the list accordingly.
E.g. the input would be : cloudy, and the code adds 0 , 1, 0, 0, 0 to the list. However I have no clue how this can be done with minimal amount of code. I am very thankful for any help and hope my question is clear!