Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16694#discussion_r98141079
  
    --- Diff: python/pyspark/ml/classification.py ---
    @@ -60,6 +61,137 @@ def numClasses(self):
     
     
     @inherit_doc
    +class LinearSVC(JavaEstimator, HasFeaturesCol, HasLabelCol, 
HasPredictionCol, HasMaxIter,
    +                HasRegParam, HasTol, HasRawPredictionCol, HasFitIntercept, 
HasStandardization,
    +                HasThreshold, HasWeightCol, HasAggregationDepth, 
JavaMLWritable, JavaMLReadable):
    +    """
    +    Linear SVM Classifier 
(https://en.wikipedia.org/wiki/Support_vector_machine#Linear_SVM)
    +    This binary classifier optimizes the Hinge Loss using the OWLQN 
optimizer.
    +
    +    >>> from pyspark.sql import Row
    +    >>> from pyspark.ml.linalg import Vectors
    +    >>> bdf = sc.parallelize([
    +    ...     Row(label=1.0, weight=2.0, features=Vectors.dense(1.0)),
    +    ...     Row(label=0.0, weight=2.0, features=Vectors.sparse(1, [], 
[]))]).toDF()
    +    >>> svm = LinearSVC(maxIter=5, regParam=0.01, weightCol="weight")
    +    >>> model = svm.fit(bdf)
    +    >>> model.coefficients
    +    DenseVector([1.909])
    +    >>> model.intercept
    +    -1.0045358384178
    +    >>> model.numClasses
    +    2
    +    >>> model.numFeatures
    +    1
    +    >>> test0 = sc.parallelize([Row(features=Vectors.dense(-1.0))]).toDF()
    +    >>> result = model.transform(test0).head()
    +    >>> result.prediction
    +    0.0
    +    >>> result.rawPrediction
    +    DenseVector([2.9135, -2.9135])
    +    >>> test1 = sc.parallelize([Row(features=Vectors.sparse(1, [0], 
[1.0]))]).toDF()
    +    >>> model.transform(test1).head().prediction
    +    1.0
    +    >>> svm.setParams("vector")
    --- End diff --
    
    Put this in a unit test (tests.py), not here in the doc tests (though I 
also don't think you really need this test)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to