{"id":2116,"date":"2014-03-04T13:35:08","date_gmt":"2014-03-04T13:35:08","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=2116"},"modified":"2014-03-04T13:35:08","modified_gmt":"2014-03-04T13:35:08","slug":"valueerror-mix-label-input-types-string-number-using-labelbinarizer","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/valueerror-mix-label-input-types-string-number-using-labelbinarizer\/","title":{"rendered":"&#8220;ValueError: Mix of label input types (string and number)&#8221; when using LabelBinarizer"},"content":{"rendered":"<p>If you do this:<\/p>\n<pre lang=\"python\">\nfrom sklearn import preprocessing\nlb = preprocessing.LabelBinarizer()\nlb.fit([\"a\", 2])\n<\/pre>\n<p>You will get the following error:<\/p>\n<pre>\nValueError: Mix of label input types (string and number)\n<\/pre>\n<p>When you mix numbers and strings, it&#8217;s unclear whether you are mixing different types of classes, or if you&#8217;re mixing continuous and non-continuous data. If the latter- you don&#8217;t want the LabelBinarizer to run on the continuous data, and you should remove it, then re-add to the data later. If the former, you can convert the integers to strings.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you do this: from sklearn import preprocessing lb = preprocessing.LabelBinarizer() lb.fit([&#8220;a&#8221;, 2]) You will get the following error: ValueError: Mix of label input types (string and number) When you mix numbers and strings, it&#8217;s unclear whether you are mixing different types of classes, or if you&#8217;re mixing continuous and non-continuous data. If the latter- &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/valueerror-mix-label-input-types-string-number-using-labelbinarizer\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;&#8220;ValueError: Mix of label input types (string and number)&#8221; when using LabelBinarizer&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[198,447],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/2116"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=2116"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/2116\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=2116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=2116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=2116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}