spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From colin <colin...@sina.cn>
Subject How to get the parameters of bestmodel while using paramgrid and crossvalidator?
Date Tue, 09 Aug 2016 06:09:17 GMT
I'm using CrossValidator and paramgrid to find the best parameters of my
model.
After crossvalidate, I got a CrossValidatorModel but when I want to get the
parameters of my pipeline, there's nothing in the parameter list of
bestmodel.

Here's the code runing on jupyter notebook:
sq=SQLContext(sc)
df=sq.createDataFrame([(1,0,1),(2,0,2),(1,0,1),(2,1,2),(1,1,1),(2,1,2),(3,1,1),(2,1,2),(1,1,2)],["a","b","c"])
lableIndexer=StringIndexer(inputCol="c",outputCol="label").fit(df)
vecAssembler=VectorAssembler(inputCols=["a","b"],outputCol="featureVector")
lr=LogisticRegression(featuresCol="featureVector",labelCol="label")
pip=Pipeline()
pip.setStages([lableIndexer,vecAssembler,lr])
grid=ParamGridBuilder().addGrid(lr.maxIter,[10,20,30,40]).build()
evaluator=MulticlassClassificationEvaluator()
cv=CrossValidator(estimator=pip,estimatorParamMaps=grid,evaluator=evaluator,numFolds=3)
cvModel=cv.fit(df)
cvPrediction=cvModel.transform(df)
cvPrediction
0.666666
cvModel.bestModel.params
[]

There's no error, so what's wrong?



--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/How-to-get-the-parameters-of-bestmodel-while-using-paramgrid-and-crossvalidator-tp27497.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe e-mail: user-unsubscribe@spark.apache.org


Mime
View raw message