I have a custom Python function that uses the input of a model to create a data frame of the predicted y-values, probabilities, and some other features. I am trying to extract the physical variable name and use it as column within the data frame. In the function the "model" variable signifies a defined model. Is it possible extract the physical string and use it to create a new column?
Below is an extremely basic reproducible example of my code
from sklearn.linear_model import LogisticRegression
import pandas as pd```
df = {'odds_h': [150, 200, -300]}
log_reg = LogisticRegression()
def model_summary(model):
df_summary = pd.DataFrame({'odds_h': df['odds_h'],
'model_type': model})
return(df_summary)
model_summary(log_reg)
Here is what the data frame output currently displays
Here is the intended output