Skip to content
CampusEduX

Problem 2: Compare Random Forest with a Single Decision Tree

Easypython
Learn the Concept: Random Forest

Problem Description

Write a Python program that trains both a Decision Tree and a Random Forest on the same dataset, and compares their predictions on the same new data point.

Input

A labeled dataset and one new data point.

Output

Predictions from both models.

Constraints

  • At least 8 labeled training examples.

Example Input

text
X=[[1],[2],[3],[7],[8],[9],[10],[11]], y=[0,0,0,1,1,1,1,1], new=[[6]]

Example Output

text
Decision Tree prediction: [1] Random Forest prediction: [1]

Concepts Covered

DecisionTreeClassifier, RandomForestClassifier, model comparison.

Related Problems

  • Problem 1: Train a Basic Random Forest Classifier
    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...