Section 6.4 ActiveCode Challenge: Decision Tree Classifier for Obstacle Sorting
In this exercise, you will build a pure Python decision tree classification loop. Standard Runestone CodeLens and ActiveCode environments do not support external libraries like
scikit-learn or opencv. Therefore, you will write pure Python logic that mimics a decision tree classifier to sort data coordinates into "obstacle" or "free space".
Subsection 6.4.1 Section 6.4 Interactive Exercises
Subsubsection 6.4.1.1 Exercise 6.4.1: Decision Tree Classifier Challenge
Complete the decision tree classifier below to sort incoming coordinate telemetry into "OBSTACLE" vs. "FREE_SPACE".
Task:
-
Complete the
predict_decision_treefunction according to these decision rules:-
If
x_coord < 2.0ANDy_coord < 2.0, classify as"OBSTACLE". -
Otherwise, classify as
"FREE_SPACE".
-
-
Run the script to evaluate the accuracy of your classifier against the test dataset!
You have attempted of activities on this page.
