0
$\begingroup$

I'm doing a Data Science project, and I'm on the stage of cleaning categorical features. I've been researching, and it seems that imputing the mean or median can change the distribution. Therefore, a better way would be to use logistic regression or any other model to predict null values in categorical features.

In this post, the author explains how to use logistic regression to impute null values in a binomial categorical feature. However, the categorical features that I'm using have multiple possible values.

Do you know of any approach to solve this and get an accurate imputation of null values on multi-categorical features?

Thanks!

$\endgroup$

1 Answer 1

1
$\begingroup$

I am not saying this is a good idea.

You could use multinomial models (logistic, trees). The test you posed "get an accurate imputation" is hard. Given the missing values are unknown, you can get a probabilistic answer. How accurate is a function of the data. And now you have 2 models that you need to prepare and monitor.

A bigger question - can the features be null during scoring or is this a training issue only? If the model is in production and receives missing values, you need to run the imputation model scoring to determine what value to place in the feature before scoring with the model.

Hopefully a null indicator variable is always getting set in your data. And you have already researched the missing values to see if there is a pattern, if there is meaning to the missing, why they are missing, subject matter expert rules that can replace, etc. Are these missing at random or missing not at random or ...?

$\endgroup$
2
  • $\begingroup$ Thanks for your answer! Regarding the bigger question, I'm not sure I understand what "scoring" means here, sorry! Could you please tell me what this term means in this context? Also, I'll take a look at the patterns of missing data, as you suggest at the end! (however, this project I'm doing is part of the house prices competition in Kaggle, so probably the missing data are random, but I'll check that). Lastly, given the methods that you've mentioned (multinomial models -logistic, trees), do you know of any place where I can see an example of application? Again, thank you very much! :) $\endgroup$
    – Álvaro V.
    Commented Aug 25, 2022 at 7:41
  • $\begingroup$ Scoring is when the model is in production. A model is trained on data, then new data is sent to the model to get a score. Think a car loan - a model is trained to predict who will not pay back the loan, then the model is in production scoring each loan applicant. If this is for Kaggle, there is some data set you need to send in so that would be scoring. If you check scikit learn documentation for logistic and multinomial. scikit-learn.org/stable/modules/generated/… $\endgroup$
    – Craig
    Commented Aug 25, 2022 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.