Problem 2: Compare Random Forest with a Single Decision Tree
Easypython
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
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.