python - SciKitLearn OLS regression on categorical data -


i'm running regression on dataframe has regular value columns , categorical ones.

i've used pandas.get_dummies on categorical columns , run ols on concatenated dataframe, results list every dummy column separately, , of course want re-unite them correlation.

here's how i'm doing it: (x existing array numerical columns normalized)

obj_df = df.select_dtypes(include=['object']).copy() one_hot = pd.get_dummies(obj_df, columns=["categorycolumn1","categorycolumn2", "categorycolumn3"]) df.drop(["categorycolumn1","categorycolumn2", "categorycolumn3"], axis=1, inplace=true)  df_new = pd.concat([x, one_hot], axis=1) df_new.drop(["startdatetime"], axis=1, inplace=true) df_new.head()  est = sm.ols(y.astype(float), df_new.astype(float)).fit() est.summary() 


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -