You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Bryan Cutler (JIRA)" <ji...@apache.org> on 2016/06/28 19:14:57 UTC

[jira] [Commented] (SPARK-16247) Using pyspark dataframe with pipeline and cross validator

    [ https://issues.apache.org/jira/browse/SPARK-16247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15353555#comment-15353555 ] 

Bryan Cutler commented on SPARK-16247:
--------------------------------------

I'm not sure if this is the issue, but the first parameter to {{addGrid()}} should be a {{ml,Param}} like this

{noformat}
dt = DecisionTreeClassifier(labelCol="indexedLabel", featuresCol="indexedFeatures")

paramGrid = ParamGridBuilder() \
    .addGrid(dt.maxDepth, [3, 4, 5]) \
    .build()
{noformat}

If that's not the issue, could you include more info such as the exact error you are seeing?

> Using pyspark dataframe with pipeline and cross validator
> ---------------------------------------------------------
>
>                 Key: SPARK-16247
>                 URL: https://issues.apache.org/jira/browse/SPARK-16247
>             Project: Spark
>          Issue Type: Bug
>          Components: ML
>    Affects Versions: 1.6.1
>            Reporter: Edward Ma
>
> I am using pyspark with dataframe. Using pipeline operation to train and predict the result. It is alright for single testing.
> However, I got issue when using pipeline and CrossValidator. The issue is that I expect CrossValidator use "indexedLabel" and "indexedMsg" as label and feature. Those fields are built by StringIndexer and VectorIndex. It suppose to be existed after executing pipeline. 
> Then I dig into pyspark library [python/pyspark/ml/tuning.py] (line 222, _fit function and line 239, est.fit), I found that it does not execute pipeline stage. Therefore, I cannot get "indexedLabel" and "indexedMsg". 
> Would you mind advising whether my usage is correct or not.
> Thanks.
> Here is code snippet
> // # Indexing
> labelIndexer = StringIndexer(inputCol="label", outputCol="indexedLabel").fit(extracted_data)
> featureIndexer = VectorIndexer(inputCol="extracted_msg", outputCol="indexedMsg", maxCategories=3000).fit(extracted_data)
> // # Training
> classification_model = RandomForestClassifier(labelCol="indexedLabel", featuresCol="indexedMsg", numTrees=50, maxDepth=20)
> pipeline = Pipeline(stages=[labelIndexer, featureIndexer, classification_model])
> // # Cross Validation
> paramGrid = ParamGridBuilder().addGrid(1000, (10, 100, 1000)).build()
> cvEvaluator = MulticlassClassificationEvaluator(metricName="precision")
> cv = CrossValidator(estimator=pipeline, estimatorParamMaps=paramGrid, evaluator=cvEvaluator, numFolds=10)
> cvModel = cv.fit(trainingData)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org