Created
January 27, 2019 18:19
-
-
Save sanjurm16/9688fca71dd30911d9bae9f141184853 to your computer and use it in GitHub Desktop.
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
indexer = [StringIndexer(inputCol=column_name, outputCol=column_name+"Index", handleInvalid="keep") for column_name in column_to_index] | |
assembler = VectorAssembler(inputCols=["PclassIndex","SexIndex","Age","Fare","WithFamily","EmbarkedIndex"], outputCol="features") | |
labelindexer = StringIndexer(inputCol="Survived", outputCol="label") | |
sql_transformer = SQLTransformer(statement="SELECT features, label FROM __THIS__") | |
indexer.extend([assembler, labelindexer, sql_transformer]) | |
lr = LogisticRegression(maxIter=10, regParam=0.3, elasticNetParam=0.8) | |
indexer.append(lr) | |
pipeline = Pipeline(stages=indexer) | |
model = pipeline.fit(trainingData) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment