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

    https://github.com/apache/spark/pull/16694#discussion_r98309772
  
    --- 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 --
    
    I know, there are some not great examples to follow.  It'd be nice to clean 
those out sometime...


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to