Challenge: Implementing a Random Forest
In this chapter, you will build a Random Forest using the same titanic dataset.
Also, you will calculate the cross-validation accuracy using the cross_val_score()
function
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:
for f in zip(X.columns, model.feature_importances_):
print(f)
Swipe to start coding
- 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.
Løsning
Takk for tilbakemeldingene dine!
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Awesome!
Completion rate improved to 3.57Awesome!
Completion rate improved to 3.57
Challenge: Implementing a Random Forest
In this chapter, you will build a Random Forest using the same titanic dataset.
Also, you will calculate the cross-validation accuracy using the cross_val_score()
function
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:
for f in zip(X.columns, model.feature_importances_):
print(f)
Swipe to start coding
- 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.
Løsning
Takk for tilbakemeldingene dine!
single
Awesome!
Completion rate improved to 3.57
Challenge: Implementing a Random Forest
Sveip for å vise menyen
In this chapter, you will build a Random Forest using the same titanic dataset.
Also, you will calculate the cross-validation accuracy using the cross_val_score()
function
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:
for f in zip(X.columns, model.feature_importances_):
print(f)
Swipe to start coding
- 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.
Løsning
Takk for tilbakemeldingene dine!