-
Notifications
You must be signed in to change notification settings - Fork 28.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-50869][ML][CONNECT][PYTHON] Support evaluators on ML Connet
### What changes were proposed in this pull request? This PR adds support Evaluator on ML Connect: - org.apache.spark.ml.evaluation.RegressionEvaluator - org.apache.spark.ml.evaluation.BinaryClassificationEvaluator - org.apache.spark.ml.evaluation.MulticlassClassificationEvaluator - org.apache.spark.ml.evaluation.MultilabelClassificationEvaluator - org.apache.spark.ml.evaluation.ClusteringEvaluator - org.apache.spark.ml.evaluation.RankingEvaluator ### Why are the changes needed? for parity with spark classic ### Does this PR introduce _any_ user-facing change? Yes, new evaluators supported on ML connect ### How was this patch tested? The newly added tests can pass ### Was this patch authored or co-authored using generative AI tooling? No Closes #49547 from wbo4958/evaluator.ml.connect. Authored-by: Bobby Wang <[email protected]> Signed-off-by: Ruifeng Zheng <[email protected]>
- Loading branch information
1 parent
205e382
commit ef363b6
Showing
17 changed files
with
778 additions
and
87 deletions.
There are no files selected for viewing
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
26 changes: 26 additions & 0 deletions
26
mllib/src/main/resources/META-INF/services/org.apache.spark.ml.evaluation.Evaluator
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# Spark Connect ML uses ServiceLoader to find out the supported Spark Ml evaluators. | ||
# So register the supported evaluator here if you're trying to add a new one. | ||
|
||
org.apache.spark.ml.evaluation.RegressionEvaluator | ||
org.apache.spark.ml.evaluation.BinaryClassificationEvaluator | ||
org.apache.spark.ml.evaluation.MulticlassClassificationEvaluator | ||
org.apache.spark.ml.evaluation.MultilabelClassificationEvaluator | ||
org.apache.spark.ml.evaluation.ClusteringEvaluator | ||
org.apache.spark.ml.evaluation.RankingEvaluator |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
import os | ||
import unittest | ||
|
||
from pyspark.ml.tests.test_evaluation import EvaluatorTestsMixin | ||
from pyspark.sql import SparkSession | ||
|
||
|
||
class EvaluatorParityTests(EvaluatorTestsMixin, unittest.TestCase): | ||
def setUp(self) -> None: | ||
self.spark = SparkSession.builder.remote( | ||
os.environ.get("SPARK_CONNECT_TESTING_REMOTE", "local[2]") | ||
).getOrCreate() | ||
|
||
def test_assert_remote_mode(self): | ||
from pyspark.sql import is_remote | ||
|
||
self.assertTrue(is_remote()) | ||
|
||
def tearDown(self) -> None: | ||
self.spark.stop() | ||
|
||
|
||
if __name__ == "__main__": | ||
from pyspark.ml.tests.connect.test_parity_evaluation import * # noqa: F401 | ||
|
||
try: | ||
import xmlrunner # type: ignore[import] | ||
|
||
testRunner = xmlrunner.XMLTestRunner(output="target/test-reports", verbosity=2) | ||
except ImportError: | ||
testRunner = None | ||
unittest.main(testRunner=testRunner, verbosity=2) |
Oops, something went wrong.