Created
June 6, 2021 07:13
-
-
Save AdroitAnandAI/7f24414a7ed53cb81f036a7635e6ac68 to your computer and use it in GitHub Desktop.
ML Pipeline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configure ML pipeline with three stages: tokenizer, CountVec, and LR | |
# https://spark.apache.org/docs/latest/ml-pipeline.html | |
#Refer: https://spark.apache.org/docs/latest/ml-features#tokenizer | |
tokenizer = Tokenizer(inputCol="text", outputCol="words") | |
#Refer: https://spark.apache.org/docs/latest/ml-features.html#countvectorizer | |
cv = CountVectorizer(inputCol=tokenizer.getOutputCol(), \ | |
outputCol="features", minDF=2.0) | |
lr = LogisticRegression(maxIter=10, regParam=0.001) | |
pipeline = Pipeline(stages=[tokenizer, cv, lr]) | |
# Fit the pipeline to training documents. | |
model = pipeline.fit(training) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment