zhengruifeng commented on a change in pull request #25715: 
[SPARK-28969][PYTHON][ML] OneVsRestParams parity between scala and python
URL: https://github.com/apache/spark/pull/25715#discussion_r323573836
 
 

 ##########
 File path: python/pyspark/ml/classification.py
 ##########
 @@ -1959,6 +1950,15 @@ def setParams(self, featuresCol="features", 
labelCol="label", predictionCol="pre
         kwargs = self._input_kwargs
         return self._set(**kwargs)
 
+    @since("2.0.0")
+    def setClassifier(self, value):
+        """
+        Sets the value of :py:attr:`classifier`.
+
+        .. note:: Only LogisticRegression and NaiveBayes are supported now.
 
 Review comment:
   ```python
   In [1]: from pyspark.ml.linalg import Vectors
   
   In [2]: from pyspark.sql import Row
   
   In [3]: from pyspark.ml.classification import *
   
   In [4]: svm = LinearSVC(maxIter=5, regParam=0.01)
   
   In [5]: ovr = OneVsRest(classifier=svm)
   
   In [6]: data_path = "data/mllib/sample_multiclass_classification_data.txt"
   
   In [7]: df = spark.read.format("libsvm").load(data_path)
   19/09/12 14:25:27 WARN LibSVMFileFormat: 'numFeatures' option not specified, 
determining the number of features by going though the input. If you know the 
number in advance, please specify it via 'numFeatures' option to avoid the 
extra scan.
   
   In [8]: model = ovr.fit(df)
   19/09/12 14:25:38 WARN BLAS: Failed to load implementation from: 
com.github.fommil.netlib.NativeSystemBLAS
   19/09/12 14:25:38 WARN BLAS: Failed to load implementation from: 
com.github.fommil.netlib.NativeRefBLAS
   
   In [9]: model.models[0].coefficients
   Out[9]: DenseVector([1.0653, 0.5648, 1.0451, 1.5259])
   
   In [10]: model.getClassifier()
   Out[10]: LinearSVC_1730373ceae7
   ```
   
   one more thing, OVR now support more base models. So we can del this note.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to