Problem 2: Compare Random Forest with a Single Decision Tree
Easypython
Learn the Concept: Random ForestProblem 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
textX=[[1],[2],[3],[7],[8],[9],[10],[11]], y=[0,0,0,1,1,1,1,1], new=[[6]]
Example Output
textDecision Tree prediction: [1] Random Forest prediction: [1]
Concepts Covered
DecisionTreeClassifier, RandomForestClassifier, model comparison.
Related Problems
- Problem 1: Train a Basic Random Forest ClassifierEasy · pythonSolve Problem
- Problem 3: Extract and Display Feature ImportancesEasy · pythonSolve Problem
- Problem 4: Evaluate the Effect of n_estimatorsEasy · pythonSolve Problem