Saltar al contenido principal
Página

Tema 4.1 - Ejemplo de codigo entrenando un modelo Random Forests



Resumen

Random Fore

Imagen tomada de: https://www.geeksforgeeks.org/random-forest-regression-in-python/


Acá puedes tomar el código:

#Fitting Random Forest Regression to the dataset

#import the regressor

from sklearn.ensamble import RandomForestRegressor

#create regressor object

regressor = RandomForestRegressor(n-estimators = 100, random_state = 0)

#fit the regressor with x and y data

regressor.fit(x,y)



Random Forest Classifier

Imagen tomada de: https://www.datacamp.com/tutorial/random-forests- classifier-python


Acá puedes tomar el código:

#Import Random Forest Model

from sklearn.ensamble import RandomForestClassifier

#create a Gaussian Classifier

clf = RandomForestClassifier(n_estimators = 100)

#Train the model using the training sets y_pred = clf.predict(x_test)

clf.fit(x_train, y train)

y_predict = clf.predic(x_test)

Última modificación: viernes, 20 de enero de 2023, 12:00