I'm trying to do a visualization for a Logistic Regression (LR) model for a binary classification task.
I've built an LR model to predict the gender of English text authors (male / female) using scikit-learn
in Python. I saved the model, and extracted the features and the coefficients. Now given a new random text, I would like to show the decision procedure of the model (I know how to do the actual prediction by code). For example had it been a Decision Tree model, then I'd just show the decision tree. My question is, what do I need in order to simulate the decision process of LR? Let's say I have the following text:
i hang out with my wife every weekend
And my features are: hang
, my wife
, weekend
. My model calculates TFIDF values of the features and builds a features table like so:
hang | my wife | weekend |
---|---|---|
0.01 | 0.02 | 0.03 |
And let's say the model predicts a high probability of the author being a male. Now I would like to show how it came to this decision based on some calculations. For example a (wrong but easy) way would be to say "the male-related features are more than the female-related features (and then point out the features), and thus this was classified as a male text".
So how could I show the calculations process that the model had done to come up with its decision? I'm not necessarily looking for a library to do it automatically, I only need to know the steps and then I can implement something of my own.
I hope I'm clear enough, but otherwise please let me know and I'll try to clarify it better.