Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

random forest python

from sklearn.ensemble import RandomForestClassifier

y = train_data["Survived"]

features = ["Pclass", "Sex", "SibSp", "Parch","Fare","Age"]
X = pd.get_dummies(train_data[features])
X_test = pd.get_dummies(test_data[features])

model = RandomForestClassifier(n_estimators=100, max_depth=5, random_state=1)
model.fit(X, y)
predictions = model.predict(X_test)
Comment

Random forest classifier python

import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
# Creating a bar plot
sns.barplot(x=feature_imp, y=feature_imp.index)
# Add labels to your graph
plt.xlabel('Feature Importance Score')
plt.ylabel('Features')
plt.title("Visualizing Important Features")
plt.legend()
plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: python add column with constant value 
Python :: python < 
Python :: global variable in python 
Python :: matplotlib get padding from bbox 
Python :: how to iterate over rows in pandas 
Python :: remove dict python 
Python :: python serial port 
Python :: pyplot.plot 
Python :: tkinter change ttk button color 
Python :: Python How To Convert a String to Variable Name 
Python :: package python 
Python :: jupyter notebook set password 
Python :: dataframe-name python 
Python :: np.vstack python 
Python :: global python 
Python :: how to read a excel file in python 
Python :: what are arrays in python 
Python :: migration django 
Python :: python create nested dictionary 
Python :: shape in python 
Python :: opencv python rgb to hsv 
Python :: initialize variable python 
Python :: min max code in python 
Python :: jquery datepicker disable 
Python :: odd number sum in python 
Python :: python multiclass inheritance with inputs 
Python :: non blocking socket python 
Python :: camp cretaceous.com 
Python :: pandas qcut 
Python :: error aesthetics must be either length 1 or the same as the data (3) fill 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =