2012/6/8 Randy Liu <[email protected]>:
> Is it possible to create a decision tree which has Mixed Type or even just
> String data.
> When I execute the following code to try to create a decision tree with
> String data I get a ValueError: Unable to convert String to Float
>
> clf = DecisionTreeClassifier()
> clf.fit([["foo", 1], ["bar", 0]], [0, 1])
>
> Which makes me think that this isn't possible. However my understanding of
> decision trees is that they are able to support any mix of data types.
All scikit-learn estimators are designed to work with numeric data
exclusively; however, the DictVectorizer class in
sklearn.feature_extraction can transform string features into numeric
(boolean) ones:
http://scikit-learn.org/stable/modules/feature_extraction.html#loading-features-from-dicts
HTH,
--
Lars Buitinck
Scientific programmer, ILPS
University of Amsterdam
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general