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

PREVIOUS NEXT
Code Example
Python :: pandas append dictionary to dataframe 
Python :: edit json file python 
Python :: save images cv2 
Python :: kivy fixed window 
Python :: RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() 
Python :: pandas plot xlabel 
Python :: order pandas dataframe by column values 
Python :: python install module from script 
Python :: check if number is power of 2 python 
Python :: argparse mutually exclusive 
Python :: select items from dataframe where value is null 
Python :: to extract out only year month from a date column in pandas 
Python :: age in days to age in years 
Python :: python os.getenv not working 
Python :: python capture in regex 
Python :: python get dir 
Python :: numpy random float array between 0 and 1 
Python :: ipywidgets pip 
Python :: get self file name in python 
Python :: how to print char of element in list of pytohn 
Python :: jupyter read in csv 
Python :: python get last modification time of file 
Python :: how to join a string by new line out of a list python 
Python :: np not defined 
Python :: python process id 
Python :: pandas drop values from column 
Python :: calculate mape python 
Python :: debug flask powershel 
Python :: pygame how to change a pictures hue 
Python :: plt.xlabel not working 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =