Contenido del Curso
Classification with Python
5. Comparing Models
Classification with Python
Challenge: Implementing a Random Forest
In this chapter, you will build a Random Forest using the same titanic dataset.
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/b71ff7ac-3932-41d2-a4d8-060e24b00129/RandomForestClass.png)
Also, you will calculate the cross-validation accuracy using the cross_val_score()
function
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/b71ff7ac-3932-41d2-a4d8-060e24b00129/CrossValFunc.png)
In the end, you will print the feature importances.
The feature_importances_
attribute only holds an array with importances without specifying the name of a feature.
To print the pairs ('name', importance), you can use the following syntax:
Tarea
- Import the
RandomForestClassifier
class. - Create an instance of a
RandomForestClassifier
class with default parameters and train it. - Print the cross-validation score with the
cv=10
of arandom_forest
you just built. - Print each feature's importance along with its name.
¿Todo estuvo claro?
Contenido del Curso
Classification with Python
5. Comparing Models
Classification with Python
Challenge: Implementing a Random Forest
In this chapter, you will build a Random Forest using the same titanic dataset.
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/b71ff7ac-3932-41d2-a4d8-060e24b00129/RandomForestClass.png)
Also, you will calculate the cross-validation accuracy using the cross_val_score()
function
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/b71ff7ac-3932-41d2-a4d8-060e24b00129/CrossValFunc.png)
In the end, you will print the feature importances.
The feature_importances_
attribute only holds an array with importances without specifying the name of a feature.
To print the pairs ('name', importance), you can use the following syntax:
Tarea
- Import the
RandomForestClassifier
class. - Create an instance of a
RandomForestClassifier
class with default parameters and train it. - Print the cross-validation score with the
cv=10
of arandom_forest
you just built. - Print each feature's importance along with its name.
¿Todo estuvo claro?