Horje
get top feature gridsearchcv Code Example
get top feature gridsearchcv
#when using with pipeline and gridsearch
feature_names = model.best_estimator_.named_steps['vect'].get_feature_names()
coefs = model.best_estimator_.named_steps['model'].coef_.flatten()

# Zip coefficients and names together and make a DataFrame
zipped = zip(feature_names, coefs)
df_f = pd.DataFrame(zipped, columns=["feature", "value"])

#if plotting add color
# Sort the features by the absolute value of their coefficient
df_f["abs_value"] = df_f["value"].apply(lambda x: abs(x))
df_f["colors"] = df_f["value"].apply(lambda x: "green" if x > 0 else "red")
df_f = df_f.sort_values("abs_value", ascending=False)




Python

Related
geopandas change dtype of a columns Code Example geopandas change dtype of a columns Code Example
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa5 in position 10: invalid start byte Code Example UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa5 in position 10: invalid start byte Code Example
Solve abstract model relations conflicts while using inheritance Code Example Solve abstract model relations conflicts while using inheritance Code Example
disable json dumps encode Code Example disable json dumps encode Code Example
how to average only positive number in array numpy Code Example how to average only positive number in array numpy Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7