Files
SivananthamandGitHub a869657f25 Fix python linter (#3571)
* Fix python linter

Signed-off-by: Sivanantham Chinnaiyan <[email protected]>

* Format e2e tests

Signed-off-by: Sivanantham Chinnaiyan <[email protected]>

* Format hack, docs

Signed-off-by: Sivanantham Chinnaiyan <[email protected]>

* Add py-fmt target

Signed-off-by: Sivanantham Chinnaiyan <[email protected]>

* Update python lint workflow

Signed-off-by: Sivanantham Chinnaiyan <[email protected]>

* Rebase master

Signed-off-by: Sivanantham Chinnaiyan <[email protected]>

---------

Signed-off-by: Sivanantham Chinnaiyan <[email protected]>
2024-04-05 11:15:12 -04:00

18 lines
610 B
Python

from pyspark.sql import SparkSession
from pyspark.ml import Pipeline
from pyspark.ml.classification import DecisionTreeClassifier
from pyspark.ml.feature import RFormula
from pyspark2pmml import PMMLBuilder
spark = SparkSession.builder.appName("SparkByExamples.com").getOrCreate()
df = spark.read.csv("Iris.csv", header=True, inferSchema=True)
formula = RFormula(formula="Species ~ .")
classifier = DecisionTreeClassifier()
pipeline = Pipeline(stages=[formula, classifier])
pipelineModel = pipeline.fit(df)
pmmlBuilder = PMMLBuilder(spark, df, pipelineModel)
pmmlBuilder.buildFile("DecisionTreeIris.pmml")