私はbigml.comを使用して虹彩データセットの決定木モデルを生成しました。私はこの決定木モデルをPMMLとしてダウンロードし、ローカルコンピュータの予測に使用したいと考えています。私は、一般的に機械学習のためのRを使用してロードし、私のシステムで予測のためにこのモデルを使用したい ダウンロードしたbigmlモデルをローカル予測に使用するにはどうすればよいですか?
<?xml version="1.0" encoding="utf-8"?>
<PMML version="4.2" xmlns="http://www.dmg.org/PMML-4_2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header description="Generated by BigML"/>
<DataDictionary>
<DataField dataType="double" displayName="Sepal length" name="000001" optype="continuous"/>
<DataField dataType="double" displayName="Sepal width" name="000002" optype="continuous"/>
<DataField dataType="double" displayName="Petal length" name="000003" optype="continuous"/>
<DataField dataType="double" displayName="Petal width" name="000004" optype="continuous"/>
<DataField dataType="string" displayName="Species" name="000005" optype="categorical">
<Value value="Iris-setosa"/>
<Value value="Iris-versicolor"/>
<Value value="Iris-virginica"/>
</DataField>
</DataDictionary>
<TreeModel algorithmName="mtree" functionName="classification" modelName="">
<MiningSchema>
<MiningField name="000001"/>
<MiningField name="000002"/>
<MiningField name="000003"/>
<MiningField name="000004"/>
<MiningField name="000005" usageType="target"/>
</MiningSchema>
<Node recordCount="150" score="Iris-setosa">
<True/>
<ScoreDistribution recordCount="50" value="Iris-setosa"/>
<ScoreDistribution recordCount="50" value="Iris-versicolor"/>
<ScoreDistribution recordCount="50" value="Iris-virginica"/>
<Node recordCount="100" score="Iris-versicolor">
<SimplePredicate field="000003" operator="greaterThan" value="2.45"/>
<ScoreDistribution recordCount="50" value="Iris-versicolor"/>
<ScoreDistribution recordCount="50" value="Iris-virginica"/>
<Node recordCount="46" score="Iris-virginica">
<SimplePredicate field="000004" operator="greaterThan" value="1.75"/>
<ScoreDistribution recordCount="45" value="Iris-virginica"/>
<ScoreDistribution recordCount="1" value="Iris-versicolor"/>
<Node recordCount="43" score="Iris-virginica">
<SimplePredicate field="000003" operator="greaterThan" value="4.85"/>
<ScoreDistribution recordCount="43" value="Iris-virginica"/>
</Node>
<Node recordCount="3" score="Iris-virginica">
<SimplePredicate field="000003" operator="lessOrEqual" value="4.85"/>
<ScoreDistribution recordCount="2" value="Iris-virginica"/>
<ScoreDistribution recordCount="1" value="Iris-versicolor"/>
<Node recordCount="1" score="Iris-versicolor">
<SimplePredicate field="000002" operator="greaterThan" value="3.1"/>
<ScoreDistribution recordCount="1" value="Iris-versicolor"/>
</Node>
<Node recordCount="2" score="Iris-virginica">
<SimplePredicate field="000002" operator="lessOrEqual" value="3.1"/>
<ScoreDistribution recordCount="2" value="Iris-virginica"/>
</Node>
</Node>
</Node>
<Node recordCount="54" score="Iris-versicolor">
<SimplePredicate field="000004" operator="lessOrEqual" value="1.75"/>
<ScoreDistribution recordCount="49" value="Iris-versicolor"/>
<ScoreDistribution recordCount="5" value="Iris-virginica"/>
<Node recordCount="6" score="Iris-virginica">
<SimplePredicate field="000003" operator="greaterThan" value="4.95"/>
<ScoreDistribution recordCount="4" value="Iris-virginica"/>
<ScoreDistribution recordCount="2" value="Iris-versicolor"/>
<Node recordCount="3" score="Iris-versicolor">
<SimplePredicate field="000004" operator="greaterThan" value="1.55"/>
<ScoreDistribution recordCount="2" value="Iris-versicolor"/>
<ScoreDistribution recordCount="1" value="Iris-virginica"/>
<Node recordCount="1" score="Iris-virginica">
<SimplePredicate field="000003" operator="greaterThan" value="5.45"/>
<ScoreDistribution recordCount="1" value="Iris-virginica"/>
</Node>
<Node recordCount="2" score="Iris-versicolor">
<SimplePredicate field="000003" operator="lessOrEqual" value="5.45"/>
<ScoreDistribution recordCount="2" value="Iris-versicolor"/>
</Node>
</Node>
<Node recordCount="3" score="Iris-virginica">
<SimplePredicate field="000004" operator="lessOrEqual" value="1.55"/>
<ScoreDistribution recordCount="3" value="Iris-virginica"/>
</Node>
</Node>
<Node recordCount="48" score="Iris-versicolor">
<SimplePredicate field="000003" operator="lessOrEqual" value="4.95"/>
<ScoreDistribution recordCount="47" value="Iris-versicolor"/>
<ScoreDistribution recordCount="1" value="Iris-virginica"/>
<Node recordCount="1" score="Iris-virginica">
<SimplePredicate field="000004" operator="greaterThan" value="1.65"/>
<ScoreDistribution recordCount="1" value="Iris-virginica"/>
</Node>
<Node recordCount="47" score="Iris-versicolor">
<SimplePredicate field="000004" operator="lessOrEqual" value="1.65"/>
<ScoreDistribution recordCount="47" value="Iris-versicolor"/>
</Node>
</Node>
</Node>
</Node>
<Node recordCount="50" score="Iris-setosa">
<SimplePredicate field="000003" operator="lessOrEqual" value="2.45"/>
<ScoreDistribution recordCount="50" value="Iris-setosa"/>
</Node>
</Node>
</TreeModel>
</PMML>
bigmlから
PMMLモデル。 R自体にはpmmlパッケージがありますが、use it for predictionには不可能と思われます。このPMMLモデルをRの予測に使用できる他の方法はありますか?可能であれば、このPMMLモデルをpythonやwekaなどの他の言語でも使用できますか?はいの場合はどうすればいいですか(コードが必要です)。
のpythonモデルbigml
def predict_species(sepal_width=None,
petal_length=None,
petal_width=None):
""" Predictor for Species from
This is perhaps the best known database to be found in the pattern recognition literature. Fisher's paper is a classic
in the field and is referenced frequently to this day. (See Duda & Hart, for example.) The data set contains 3 classes
of 50 instances each, where each class refers to a type of iris plant.
Source
Iris Data Set[*]
Bache, K. & Lichman, M. (2013). UCI Machine Learning Repository[*]. Irvine, CA: University of California, School of Information and Computer Science.
[*]Iris Data Set: http://archive.ics.uci.edu/ml/datasets/Iris
[*]UCI Machine Learning Repository: http://archive.ics.uci.edu/ml
"""
if (petal_length is None):
return u'Iris-setosa'
if (petal_length > 2.45):
if (petal_width is None):
return u'Iris-versicolor'
if (petal_width > 1.75):
if (petal_length > 4.85):
return u'Iris-virginica'
if (petal_length <= 4.85):
if (sepal_width is None):
return u'Iris-virginica'
if (sepal_width > 3.1):
return u'Iris-versicolor'
if (sepal_width <= 3.1):
return u'Iris-virginica'
if (petal_width <= 1.75):
if (petal_length > 4.95):
if (petal_width > 1.55):
if (petal_length > 5.45):
return u'Iris-virginica'
if (petal_length <= 5.45):
return u'Iris-versicolor'
if (petal_width <= 1.55):
return u'Iris-virginica'
if (petal_length <= 4.95):
if (petal_width > 1.65):
return u'Iris-virginica'
if (petal_width <= 1.65):
return u'Iris-versicolor'
if (petal_length <= 2.45):
return u'Iris-setosa'