Skip to content
CampusEduX

Problem 1: Train a Basic Random Forest Classifier

Easypython
Learn the Concept: Random Forest

Problem Description

Write a Python program that trains a Random Forest classifier with 100 trees on a labeled dataset, and predicts the class for a new data point.

Input

A labeled dataset and one new data point.

Output

The predicted class.

Constraints

  • At least 8 labeled training examples.

Example Input

text
X=[[1,60],[2,65],[8,95],[9,98],[4,72],[6,88],[3,68],[7,91]], y=[0,0,1,1,0,1,0,1], new=[[5,80]]

Example Output

text
Prediction: [1]

Concepts Covered

RandomForestClassifier, n_estimators, .fit(), .predict().

Related Problems

  • Problem 2: Compare Random Forest with a Single Decision Tree
    Easy · python
    Solve Problem
  • Problem 3: Extract and Display Feature Importances
    Easy · python
    Solve Problem
  • Problem 4: Evaluate the Effect of n_estimators
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...