Questions tagged [dummy-variable]

Dummy or indicator variables are used to include categorical or qualitative variables in a regression model.

868 questions
-1
votes
1 answer

Python transforms 0 to 0.693147180559945

I created a dataframe in R with a column that holds dummy variables (thus 1 or 0) and saved it to file using write.table(my_df,"my_df.txt",sep=" ", eol="\r\n", row.names=FALSE) Then, I read the file into Python using with open('./my_df.txt', 'r') as…
hyhno01
  • 177
  • 8
-1
votes
1 answer

How to use regular expressions for making dummies?

For instance, I have reviews column and I want to extract words and create dummy variables based on them. I use that but can't use regular expressions here: df = df['reviews'].str.contains('good').astype(int) How can I use regular expressions here…
Said Taxmezov
  • 67
  • 1
  • 7
-1
votes
1 answer

Generate a seasonal dummy

I would like to create a seasonal dummy. Specifically, I want the variable to equal 1 every June and 0 otherwise. I would like the dummy variable output stored in mat1[,2] Setup: start = as.Date("1926-07-01") end = as.Date("2019-07-01") dates =…
JC3019
  • 363
  • 1
  • 9
-1
votes
1 answer

What to do if we have multiple categorical columns multi class?

If dataset have multiple categorical values then do we need to perform OneHotEncoding on all of the categorical data, and then how to remove problem of dummy variable.
-1
votes
1 answer

"object ... not found" with randomForest

I am quite new to R world. I'm currently working on a flight delay prediction. I'm getting "object 'date01-01-2004' not found" even though it is present. I tried converting all the factors into dummy variables and doing random forest on…
-1
votes
1 answer

ValueError: setting an array element with a sequence?

Why am i getting this error message? Here are the variables that are included in my code. The columns they include are all dummy variables: country_cols = wine_dummies.loc[:, 'country_Chile':'country_US'] variety_cols = wine_dummies.loc[:,…
GuyGuyGuy
  • 75
  • 1
  • 5
-1
votes
2 answers

How to view dummy variables

I have a variable (FTA) that has 2 options (yes or no), and I want to create a dummy variable to replace it with yes=1 and no=0. From time period (t) 3 and onwards, it should equal 1, and before that should be 0. df<-dummy.data.frame(df,…
-1
votes
1 answer

Generating 3.000.000 strings of length 11 in R

Apparently if I try this: # first grab the package install.packages("stringi") library(stringi) # and then try to generate some serious dummy data my_try <- as.vector(sample(1111111111:99999999999,3000000,replace=T)) R will say NOPE, sorry: Error:…
nick88
  • 118
  • 1
  • 8
-1
votes
1 answer

How to avoid dummy variable trap for multiple category in one column

I am working on a regression problem. I have a categorical column which has 24 categorical value.One-hot encoding is showing too many dummy variable. Is there a way to avoid multiple dummy variable trap. Kindly guide me here is my sample of the…
-1
votes
1 answer

Python scikit-learn: How do I convert decision tree leaves to dummy variables?

I am using scikit-learn DecisionTreeClassifier to build a decision tree. Assume that a given decision tree has 6 leaf/terminal nodes (A, B, C, D, E and F). I now want to assign the original records coded as to which leaf/terminal node they would…
-1
votes
1 answer

function in R that creates dummies for given time period

There is a data frame like this: The first two columns in the df describe the start date (month and year) and the end date (month and year). Column names describe every single month and year of a certain time period. I need a function/loop that…
Jojo
  • 1
  • 3
-1
votes
1 answer

Code to estimate an OLS fixed effects dummy variable in R

I am looking for a command (not the total code) to estimate an OLS fixed effects dummy variable model that includes a fixed effect for each state in my data frame (balanced panel dataset). My data frame includes states, years, and multiple…
-1
votes
1 answer

Python Scikit Learn, LinearRegression, Dummy Variable lead to different in shape

I've worked around with Scikit Learn Library for Machine Learning purpose. I got some problem related to Dummy variable while using Regression. I have 2 set of sample for Training set and Test set. Actually, program uses Training set to create…
-1
votes
1 answer

Change a string variable into a set of categorical variables in one command

Say I have a categorical variable, for example a country column in a table. How can I quickly add dummy variables for each category--WITH A RELEVANT NAME? So if the column is for country, the variable for whether the person lives in the USA would…
Dan
  • 63
  • 2
  • 6
-1
votes
2 answers

Imputing NAs for factorial variables NAs & Converting them to dummy variables

I have a dataframe, in which some of the variables (columns) are factorial, when for some records I have missing values (NA). Questions are: What is the correct approach of replacing\imputing NAs in factorial variables? e.g VarX with 4 Levels {"A",…
Adiel
  • 1,203
  • 3
  • 18
  • 31