0001 ---
0002 layout: global
0003 title: PMML model export - RDD-based API
0004 displayTitle: PMML model export - RDD-based API
0005 license: |
0006 Licensed to the Apache Software Foundation (ASF) under one or more
0007 contributor license agreements. See the NOTICE file distributed with
0008 this work for additional information regarding copyright ownership.
0009 The ASF licenses this file to You under the Apache License, Version 2.0
0010 (the "License"); you may not use this file except in compliance with
0011 the License. You may obtain a copy of the License at
0012
0013 http://www.apache.org/licenses/LICENSE-2.0
0014
0015 Unless required by applicable law or agreed to in writing, software
0016 distributed under the License is distributed on an "AS IS" BASIS,
0017 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0018 See the License for the specific language governing permissions and
0019 limitations under the License.
0020 ---
0021
0022 * Table of contents
0023 {:toc}
0024
0025 ## spark.mllib supported models
0026
0027 `spark.mllib` supports model export to Predictive Model Markup Language ([PMML](http://en.wikipedia.org/wiki/Predictive_Model_Markup_Language)).
0028
0029 The table below outlines the `spark.mllib` models that can be exported to PMML and their equivalent PMML model.
0030
0031 <table class="table">
0032 <thead>
0033 <tr><th>spark.mllib model</th><th>PMML model</th></tr>
0034 </thead>
0035 <tbody>
0036 <tr>
0037 <td>KMeansModel</td><td>ClusteringModel</td>
0038 </tr>
0039 <tr>
0040 <td>LinearRegressionModel</td><td>RegressionModel (functionName="regression")</td>
0041 </tr>
0042 <tr>
0043 <td>RidgeRegressionModel</td><td>RegressionModel (functionName="regression")</td>
0044 </tr>
0045 <tr>
0046 <td>LassoModel</td><td>RegressionModel (functionName="regression")</td>
0047 </tr>
0048 <tr>
0049 <td>SVMModel</td><td>RegressionModel (functionName="classification" normalizationMethod="none")</td>
0050 </tr>
0051 <tr>
0052 <td>Binary LogisticRegressionModel</td><td>RegressionModel (functionName="classification" normalizationMethod="logit")</td>
0053 </tr>
0054 </tbody>
0055 </table>
0056
0057 ## Examples
0058 <div class="codetabs">
0059
0060 <div data-lang="scala" markdown="1">
0061 To export a supported `model` (see table above) to PMML, simply call `model.toPMML`.
0062
0063 As well as exporting the PMML model to a String (`model.toPMML` as in the example above), you can export the PMML model to other formats.
0064
0065 Refer to the [`KMeans` Scala docs](api/scala/org/apache/spark/mllib/clustering/KMeans.html) and [`Vectors` Scala docs](api/scala/org/apache/spark/mllib/linalg/Vectors$.html) for details on the API.
0066
0067 Here a complete example of building a KMeansModel and print it out in PMML format:
0068 {% include_example scala/org/apache/spark/examples/mllib/PMMLModelExportExample.scala %}
0069
0070 For unsupported models, either you will not find a `.toPMML` method or an `IllegalArgumentException` will be thrown.
0071
0072 </div>
0073
0074 </div>