pd.DataFrame(lm.coef_,X.columns,columns=['Coeff']) 1

pd.DataFrame(lm.coef_,X.columns,columns=[‘Coeff’])

pd.DataFrame({"Feature":X_train.columns.tolist(),"Coefficients":logreg.coef_[0]})

Here is what the above code is Doing:
1. We are creating a new dataframe with two columns: Feature and Coefficients.
2. We are using the .columns.tolist() method to get the column names of the X_train dataframe.
3. We are using the .coef_[0] method to get the coefficients of the logreg model.
4. We are using the .tolist() method to convert the coefficients into a list.

Similar Posts