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

bookChallenge: Random Forest

Opgave

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.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 4
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

Suggested prompts:

Can you explain this in simpler terms?

What are the main points I should remember?

Can you give me an example?

close

bookChallenge: Random Forest

Stryg for at vise menuen

Opgave

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.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 4
single

single

some-alt