Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Random Forest | Bagging and Random Forests
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Ensemble Learning Techniques with Python

bookChallenge: Random Forest

Tâche

Swipe to start coding

Train and evaluate a Random Forest Classifier on the Iris dataset. Your task is to:

  1. Load the dataset using sklearn.datasets.load_iris().
  2. Split the data into training and testing sets (test_size=0.3, random_state=42).
  3. Train a RandomForestClassifier with:
    • n_estimators=100,
    • max_depth=4,
    • random_state=42.
  4. Predict labels on the test set.
  5. Compute and print the accuracy score of your model.
  6. Store the trained model in a variable named rf_model and predictions in y_pred.

Solution

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 4
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

close

bookChallenge: Random Forest

Glissez pour afficher le menu

Tâche

Swipe to start coding

Train and evaluate a Random Forest Classifier on the Iris dataset. Your task is to:

  1. Load the dataset using sklearn.datasets.load_iris().
  2. Split the data into training and testing sets (test_size=0.3, random_state=42).
  3. Train a RandomForestClassifier with:
    • n_estimators=100,
    • max_depth=4,
    • random_state=42.
  4. Predict labels on the test set.
  5. Compute and print the accuracy score of your model.
  6. Store the trained model in a variable named rf_model and predictions in y_pred.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 4
single

single

some-alt