logreg = LogisticRegression()
logreg.fit(X_train,y_train)
print(logreg.coef_ )
print(X.columns)
How can I zip the logreg.coef_ long with their column names? Thank you :)
Here is one way to do it:
# Create lists
column_labels = X.columns.tolist()
coef = logreg.coef_.squeeze().tolist()
# Zip together
labels_coef = list(zip(column_labels, coef))
# Verify the result
print(labels_coef)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.