{"action":"created","issue":{"url":"https://api.github.com/repos/jpmml/sklearn2pmml/issues/5","repository_url":"https://api.github.com/repos/jpmml/sklearn2pmml","labels_url":"https://api.github.com/repos/jpmml/sklearn2pmml/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/jpmml/sklearn2pmml/issues/5/comments","events_url":"https://api.github.com/repos/jpmml/sklearn2pmml/issues/5/events","html_url":"https://github.com/jpmml/sklearn2pmml/issues/5","id":137999658,"number":5,"title":"Random Forest Conversions and Consumption ","user":{"login":"koinadn","id":17600872,"avatar_url":"https://avatars.githubusercontent.com/u/17600872?v=3","gravatar_id":"","url":"https://api.github.com/users/koinadn","html_url":"https://github.com/koinadn","followers_url":"https://api.github.com/users/koinadn/followers","following_url":"https://api.github.com/users/koinadn/following{/other_user}","gists_url":"https://api.github.com/users/koinadn/gists{/gist_id}","starred_url":"https://api.github.com/users/koinadn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koinadn/subscriptions","organizations_url":"https://api.github.com/users/koinadn/orgs","repos_url":"https://api.github.com/users/koinadn/repos","events_url":"https://api.github.com/users/koinadn/events{/privacy}","received_events_url":"https://api.github.com/users/koinadn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-02T21:35:58Z","updated_at":"2016-03-03T22:59:59Z","closed_at":null,"body":"Hello,\r\n\r\nI'm having a few issues in testing a random forest classifier from scklearn2pmml in JPMML. I'm producing a simple PMML file from the code here:\r\n```\r\nfrom sklearn.datasets import load_iris\r\nfrom sklearn.decomposition import PCA\r\n\r\nimport pandas\r\nimport sklearn_pandas\r\n\r\niris = load_iris()\r\n\r\niris_df = pandas.concat((pandas.DataFrame(iris.data[:, :], columns = [\"Sepal.Length\", \"Sepal.Width\", \"Petal.Length\", \"Petal.Width\"]), pandas.DataFrame(iris.target, columns = [\"Species\"])), axis = 1)\r\n\r\niris_mapper = sklearn_pandas.DataFrameMapper([('Sepal.Length',None),\r\n                                              ('Sepal.Width', None), \r\n                                              ('Petal.Width', None),\r\n                                              ('Petal.Width', None),\r\n                                              ('Species',None)])\r\n\r\niris = iris_mapper.fit_transform(iris_df)\r\n\r\nfrom sklearn.ensemble import RandomForestClassifier\r\n\r\niris_X = iris[:, 0:4]\r\niris_y = iris[:, 4]\r\n\r\niris_classifier = RandomForestClassifier(n_estimators=10)\r\niris_classifier.fit(iris_X, iris_y)\r\n\r\nfrom sklearn2pmml import sklearn2pmml\r\n\r\nsklearn2pmml(iris_classifier, iris_mapper, \"randomforest.pmml\")\r\n```\r\n\r\n\r\n__________________________________________________________________\r\n**1.** I'd like to do no transformations across my data set. Leaving them all blank transforms the data type from double to float.\r\n\r\n```\r\n            <DerivedField name=\"x1\" optype=\"continuous\" dataType=\"float\">\r\n                <FieldRef field=\"Sepal.Length\"/>\r\n```\r\n\r\nThis causes an issue with JPMML throwing the following error:\r\n```\r\norg.jpmml.evaluator.TypeCheckException: Expected FLOAT, but got DOUBLE (5.3)\r\n\tat org.jpmml.evaluator.TypeUtil.toFloat(TypeUtil.java:456)\r\n\tat org.jpmml.evaluator.TypeUtil.cast(TypeUtil.java:330)\r\n\tat org.jpmml.evaluator.TypeUtil.parseOrCast(TypeUtil.java:61)\r\n\tat org.jpmml.evaluator.FieldValueUtil.create(FieldValueUtil.java:92)\r\n\tat org.jpmml.evaluator.FieldValueUtil.refine(FieldValueUtil.java:144)\r\n\tat org.jpmml.evaluator.FieldValueUtil.refine(FieldValueUtil.java:116)\r\n\tat org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:82)\r\n\tat org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:63)\r\n\tat org.jpmml.evaluator.PredicateUtil.evaluateSimplePredicate(PredicateUtil.java:95)\r\n\tat org.jpmml.evaluator.PredicateUtil.evaluate(PredicateUtil.java:54)\r\n\tat org.jpmml.evaluator.TreeModelEvaluator.evaluateNode(TreeModelEvaluator.java:171)\r\n\tat org.jpmml.evaluator.TreeModelEvaluator.handleTrue(TreeModelEvaluator.java:186)\r\n\tat org.jpmml.evaluator.TreeModelEvaluator.evaluateTree(TreeModelEvaluator.java:139)\r\n\tat org.jpmml.evaluator.TreeModelEvaluator.evaluateClassification(TreeModelEvaluator.java:111)\r\n\tat org.jpmml.evaluator.TreeModelEvaluator.evaluate(TreeModelEvaluator.java:80)\r\n\tat org.jpmml.evaluator.MiningModelEvaluator.evaluateSegmentation(MiningModelEvaluator.java:463)\r\n\tat org.jpmml.evaluator.MiningModelEvaluator.evaluateClassification(MiningModelEvaluator.java:244)\r\n\tat org.jpmml.evaluator.MiningModelEvaluator.evaluate(MiningModelEvaluator.java:133)\r\n\tat org.jpmml.evaluator.MiningModelEvaluator.evaluate(MiningModelEvaluator.java:106)\r\n\tat org.jpmml.evaluator.ModelEvaluator.evaluate(ModelEvaluator.java:263)\r\n\tat com.ea.eadp.risk.service.pmml.impl.PMMLEvaluatorImpl.evaluate(PMMLEvaluatorImpl.java:114)\r\n\tat com.ea.eadp.risk.service.pmml.impl.PMMLLoadTestServiceImpl.evaluate(PMMLLoadTestServiceImpl.java:167)\r\n\tat com.ea.eadp.risk.service.pmml.impl.PMMLLoadTestServiceImpl.runLoadTest(PMMLLoadTestServiceImpl.java:99)\r\n\tat com.ea.eadp.risk.service.pmml.impl.PMMLLoadTestServiceImpl.runLoadTest(PMMLLoadTestServiceImpl.java:31)\r\n\tat com.ea.eadp.test.jpmml.Program.main(Program.java:22)\r\n```\r\n\r\nIs there a way to not use DataFrameMapper or would I have to manually change each of the float types back into double?\r\n\r\n__________________________________________________________________\r\n**2.** Changing the above issue, JPMML complains about the the model with the following error and I'm unable to evaluate it. Any ideas on what is the cause of this?\r\n\r\n```\r\norg.jpmml.evaluator.TypeCheckException: Expected org.jpmml.evaluator.HasProbability, but got org.jpmml.evaluator.ClassificationMap (ClassificationMap{type=VOTE, vote_entries=[0=0.0, 1=0.3, 2=0.7]})\r\n\tat org.jpmml.evaluator.OutputUtil.asResultFeature(OutputUtil.java:862)\r\n\tat org.jpmml.evaluator.OutputUtil.getProbability(OutputUtil.java:489)\r\n\tat org.jpmml.evaluator.OutputUtil.evaluate(OutputUtil.java:182)\r\n\tat org.jpmml.evaluator.MiningModelEvaluator.evaluate(MiningModelEvaluator.java:143)\r\n\tat org.jpmml.evaluator.MiningModelEvaluator.evaluate(MiningModelEvaluator.java:106)\r\n\tat org.jpmml.evaluator.ModelEvaluator.evaluate(ModelEvaluator.java:263)\r\n\tat com.ea.eadp.risk.service.pmml.impl.PMMLEvaluatorImpl.evaluate(PMMLEvaluatorImpl.java:114)\r\n\tat com.ea.eadp.risk.service.pmml.impl.PMMLLoadTestServiceImpl.evaluate(PMMLLoadTestServiceImpl.java:167)\r\n\tat com.ea.eadp.risk.service.pmml.impl.PMMLLoadTestServiceImpl.runLoadTest(PMMLLoadTestServiceImpl.java:99)\r\n\tat com.ea.eadp.risk.service.pmml.impl.PMMLLoadTestServiceImpl.runLoadTest(PMMLLoadTestServiceImpl.java:31)\r\n\tat com.ea.eadp.test.jpmml.Program.main(Program.java:22)\r\n\r\n```\r\n\r\n\r\nThank you!\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/jpmml/sklearn2pmml/issues/comments/192007568","html_url":"https://github.com/jpmml/sklearn2pmml/issues/5#issuecomment-192007568","issue_url":"https://api.github.com/repos/jpmml/sklearn2pmml/issues/5","id":192007568,"user":{"login":"koinadn","id":17600872,"avatar_url":"https://avatars.githubusercontent.com/u/17600872?v=3","gravatar_id":"","url":"https://api.github.com/users/koinadn","html_url":"https://github.com/koinadn","followers_url":"https://api.github.com/users/koinadn/followers","following_url":"https://api.github.com/users/koinadn/following{/other_user}","gists_url":"https://api.github.com/users/koinadn/gists{/gist_id}","starred_url":"https://api.github.com/users/koinadn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koinadn/subscriptions","organizations_url":"https://api.github.com/users/koinadn/orgs","repos_url":"https://api.github.com/users/koinadn/repos","events_url":"https://api.github.com/users/koinadn/events{/privacy}","received_events_url":"https://api.github.com/users/koinadn/received_events","type":"User","site_admin":false},"created_at":"2016-03-03T22:59:59Z","updated_at":"2016-03-03T22:59:59Z","body":"Thanks again for the quick repsonse.\r\n\r\nI tested the same code with the original PCA transformation in the example:\r\n```\r\niris_mapper = sklearn_pandas.DataFrameMapper([\r\n    ([\"Sepal.Length\", \"Sepal.Width\", \"Petal.Length\", \"Petal.Width\"], PCA(n_components = 3)),\r\n    (\"Species\", None)\r\n])\r\n```\r\nAnd the PMML was consumed and evaluated properly so that does seem to be the cause of the error. \r\n\r\nI do believe there are some cases where no transformations would be used so that would be nice to have.\r\n\r\nThank you."}}