Is there any way to specify the label encoding in
preprocessing.LabelEncoder() ?

My targets are in string and I want to convert them into numeric values.
preprocessing.LabelEncoder() encodes always as 0,1,2 while I would like
specify the numeric code.


target_str = ['setosa', 'versicolor', 'virginica', 'setosa', 'setosa',
 'versicolor']


le = preprocessing.LabelEncoder()

target_int =le.fit(target_str).transform(target_str)


target_int

Out[10]: array([0, 1, 2, 0, 0, 1])


I would like to specify targets as


target_code = {'setosa':100, 'versicolor': 150,  'virginica':155}


and want to convert target_str to target_int as


target_int

Out[11]: array([100, 150, 155, 100, 100, 150])



Thanks

--
Sheila
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to