Skip to content

[SPARK-24058][ML][PySpark] Default Params in ML should be saved separately: Python API - #21153

Closed
viirya wants to merge 6 commits into
apache:masterfrom
viirya:SPARK-24058
Closed

[SPARK-24058][ML][PySpark] Default Params in ML should be saved separately: Python API#21153
viirya wants to merge 6 commits into
apache:masterfrom
viirya:SPARK-24058

Conversation

@viirya

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

See SPARK-23455 for reference. Now default params in ML are saved separately in metadata file in Scala. We must change it for Python for Spark 2.4.0 as well in order to keep them in sync.

How was this patch tested?

Added test.

@SparkQA

Copy link
Copy Markdown

Test build #89840 has finished for PR 21153 at commit 0e9b18a.

  • This patch fails Python style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

Copy link
Copy Markdown

Test build #89841 has finished for PR 21153 at commit f32350f.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@viirya

Copy link
Copy Markdown
MemberAuthor

cc @jkbradley@dbtsai

jsonParams = paramMap
else:
for p in params:
jsonParams[p.name] = params[p]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think use _paramMap.copy() will be simpler.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_paramMap's keys are Param not string.

# Default param values
jsonDefaultParams = {}
for p in instance._defaultParamMap:
jsonDefaultParams[p.name] = instance._defaultParamMap[p]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar, use _defaultParamMap.copy()

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

Comment threadpython/pyspark/ml/util.py Outdated
for paramName in metadata['defaultParamMap']:
param = instance.getParam(paramName)
paramValue = metadata['defaultParamMap'][paramName]
instance._setDefault(**{param.name: paramValue})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove line param = instance.getParam(paramName) and change this line to
instance._setDefault(**{paramName: paramValue})

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right. My bad.

@SparkQA

Copy link
Copy Markdown

Test build #89924 has finished for PR 21153 at commit 526fa4a.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@jkbradleyjkbradley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a quick comment about moving version utils to a separate PR. I'll try to review the other parts soon. Thanks!

Comment threadpython/pyspark/util.py Outdated
return argspec


def majorMinorVersion(version):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this affects Spark core, it might be nice to put this in a separate PR. Also, shall we make this match the Scala API?

@viiryaviiryaMay 1, 2018

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, shall we make this match the Scala API?

Do you mean to throw exception when unable to parse Spark version?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please, a few things:

  • throw exception when unable to parse
  • make it a static method of a class pyspark.util.VersionUtils
  • add unit test

@SparkQA

Copy link
Copy Markdown

Test build #90393 has finished for PR 21153 at commit 86fa433.

  • This patch fails Python style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

Copy link
Copy Markdown

Test build #90394 has finished for PR 21153 at commit b47beab.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@jkbradley

Copy link
Copy Markdown
Member

Would you mind rebasing this off of the upstream master branch? I'm having trouble running the tests for this PR locally.

@viirya

Copy link
Copy Markdown
MemberAuthor

Done. Can you try again?

@SparkQA

Copy link
Copy Markdown

Test build #90486 has finished for PR 21153 at commit ce84137.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@viirya

Copy link
Copy Markdown
MemberAuthor

Not sure why AppVeyor build failed. How to re-trigger AppVeyor build?

@SparkQA

Copy link
Copy Markdown

Test build #4179 has finished for PR 21153 at commit ce84137.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@jkbradleyjkbradley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. This LGTM except for the small typo (Hopefully fixing it will re-run the Appveyor test)

Comment threadpython/pyspark/ml/util.py Outdated
- sparkVersion
- uid
- paramMap
- defalutParamMap (since 2.4.0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: default

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@SparkQA

Copy link
Copy Markdown

Test build #90612 has finished for PR 21153 at commit dc59375.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@viirya

Copy link
Copy Markdown
MemberAuthor

OK. Looks like AppVeyor build is ok now.

@jkbradley

Copy link
Copy Markdown
Member

OK thanks @viirya !
Merging with master

@viirya

Copy link
Copy Markdown
MemberAuthor

Thanks @jkbradley@WeichenXu123

@viirya
viirya deleted the SPARK-24058 branch December 27, 2023 18:35
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@viirya@SparkQA@jkbradley@WeichenXu123