Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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)
Comment

PREVIOUS NEXT
Code Example
Python :: django admin link column display links 
Python :: What is shadows built in name? 
Python :: pandas dtodays date csv 
Python :: select randomly from list in loop 
Python :: pytest rerun last failed 
Python :: with statement python 3 files 
Python :: pandas split coordinate tuple 
Python :: how to make python faster 
Python :: subtract 2 datetime objects django 
Python :: django column to have duplicate of other 
Python :: convert darkflow yolov3 tensorflow lite 
Python :: python project pick text color according to background 
Python :: first_last6 
Python :: readme python convert to pdf 
Python :: duplicate finder python modules 
Python :: list comprehensions with dates 
Python :: fix certain parameters during curve fit python lambda 
Python :: python consecutive numbers difference between 
Python :: pandas isolate data lower than a certain percentage 
Python :: how to draw triangle in pygame 
Python :: python fibbonacci 
Python :: get the values of your aws tags from ec2 instance 
Python :: parsing a file and adding a number at starting of every line sentence python 
Python :: how to use lambda function in python 
Python :: pandas corr get couple value 
Python :: python how to close the turtle tab on click 
Python :: pandas query return column 
Python :: Solve abstract model relations conflicts while using inheritance 
Python :: raise httperror(req.full_url, code, msg, hdrs, fp) urllib.error.httperror: http error 429: too many requests 
Python :: python weekly aggreation string time 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =