How to input test data using the DecisionTree module in python?
Posted
by
lifera1n
on Stack Overflow
See other posts from Stack Overflow
or by lifera1n
Published on 2012-07-09T19:50:37Z
Indexed on
2012/07/09
21:15 UTC
Read the original article
Hit count: 187
python
|machine-learning
On the Python DescisionTree module homepage (DecisionTree-1.6.1), they give a piece of example code. Here it is:
dt = DecisionTree( training_datafile = "training.dat", debug1 = 1 )
dt.get_training_data()
dt.show_training_data()
root_node = dt.construct_decision_tree_classifier()
root_node.display_decision_tree(" ")
test_sample = ['exercising=>never', 'smoking=>heavy',
'fatIntake=>heavy', 'videoAddiction=>heavy']
classification = dt.classify(root_node, test_sample)
print "Classification: ", classification
My question is: How can I specify sample data (test_sample here) from variables? On the project homepage, it says: "You classify new data by first constructing a new data vector:" I have searched around but have been unable to find out what a data vector is or the answer to my question.
Any help would be appreciated!
© Stack Overflow or respective owner