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

Oppgave

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

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 4
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

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

Sveip for å vise menyen

Oppgave

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 desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 4
single

single

some-alt