Skip to content

Commit 7e43739

Browse files
jkbradleycmonkey
authored andcommitted
[SPARK-19389][ML][PYTHON][DOC] Minor doc fixes for ML Python Params and LinearSVC
## What changes were proposed in this pull request? * Removed Since tags in Python Params since they are inherited by other classes * Fixed doc links for LinearSVC ## How was this patch tested? * doc tests * generating docs locally and checking manually Author: Joseph K. Bradley <[email protected]> Closes apache#16723 from jkbradley/pyparam-fix-doc.
1 parent e285f36 commit 7e43739

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

mllib/src/main/scala/org/apache/spark/ml/classification/LinearSVC.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ private[classification] trait LinearSVCParams extends ClassifierParams with HasR
4747
/**
4848
* :: Experimental ::
4949
*
50-
* Linear SVM Classifier (https://en.wikipedia.org/wiki/Support_vector_machine#Linear_SVM)
50+
* <a href = "https://en.wikipedia.org/wiki/Support_vector_machine#Linear_SVM">
51+
* Linear SVM Classifier</a>
5152
*
5253
* This binary classifier optimizes the Hinge Loss using the OWLQN optimizer.
5354
*

python/pyspark/ml/classification.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ class LinearSVC(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol, Ha
6565
HasRegParam, HasTol, HasRawPredictionCol, HasFitIntercept, HasStandardization,
6666
HasThreshold, HasWeightCol, HasAggregationDepth, JavaMLWritable, JavaMLReadable):
6767
"""
68+
.. note:: Experimental
69+
6870
`Linear SVM Classifier <https://en.wikipedia.org/wiki/Support_vector_machine#Linear_SVM>`_
71+
6972
This binary classifier optimizes the Hinge Loss using the OWLQN optimizer.
7073
7174
>>> from pyspark.sql import Row
@@ -89,10 +92,6 @@ class LinearSVC(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol, Ha
8992
1.0
9093
>>> result.rawPrediction
9194
DenseVector([-1.4831, 1.4831])
92-
>>> svm.setParams("vector")
93-
Traceback (most recent call last):
94-
...
95-
TypeError: Method setParams forces keyword arguments.
9695
>>> svm_path = temp_path + "/svm"
9796
>>> svm.save(svm_path)
9897
>>> svm2 = LinearSVC.load(svm_path)
@@ -150,6 +149,8 @@ def _create_model(self, java_model):
150149

151150
class LinearSVCModel(JavaModel, JavaClassificationModel, JavaMLWritable, JavaMLReadable):
152151
"""
152+
.. note:: Experimental
153+
153154
Model fitted by LinearSVC.
154155
155156
.. versionadded:: 2.2.0

python/pyspark/ml/param/__init__.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
from abc import ABCMeta
2525
import copy
2626
import numpy as np
27-
import warnings
2827

2928
from py4j.java_gateway import JavaObject
3029

31-
from pyspark import since
3230
from pyspark.ml.linalg import DenseVector, Vector
3331
from pyspark.ml.util import Identifiable
3432

@@ -251,7 +249,6 @@ def _copy_params(self):
251249
setattr(self, name, param._copy_new_parent(self))
252250

253251
@property
254-
@since("1.3.0")
255252
def params(self):
256253
"""
257254
Returns all params ordered by name. The default implementation
@@ -264,7 +261,6 @@ def params(self):
264261
not isinstance(getattr(type(self), x, None), property)]))
265262
return self._params
266263

267-
@since("1.4.0")
268264
def explainParam(self, param):
269265
"""
270266
Explains a single param and returns its name, doc, and optional
@@ -282,15 +278,13 @@ def explainParam(self, param):
282278
valueStr = "(" + ", ".join(values) + ")"
283279
return "%s: %s %s" % (param.name, param.doc, valueStr)
284280

285-
@since("1.4.0")
286281
def explainParams(self):
287282
"""
288283
Returns the documentation of all params with their optionally
289284
default values and user-supplied values.
290285
"""
291286
return "\n".join([self.explainParam(param) for param in self.params])
292287

293-
@since("1.4.0")
294288
def getParam(self, paramName):
295289
"""
296290
Gets a param by its name.
@@ -301,31 +295,27 @@ def getParam(self, paramName):
301295
else:
302296
raise ValueError("Cannot find param with name %s." % paramName)
303297

304-
@since("1.4.0")
305298
def isSet(self, param):
306299
"""
307300
Checks whether a param is explicitly set by user.
308301
"""
309302
param = self._resolveParam(param)
310303
return param in self._paramMap
311304

312-
@since("1.4.0")
313305
def hasDefault(self, param):
314306
"""
315307
Checks whether a param has a default value.
316308
"""
317309
param = self._resolveParam(param)
318310
return param in self._defaultParamMap
319311

320-
@since("1.4.0")
321312
def isDefined(self, param):
322313
"""
323314
Checks whether a param is explicitly set by user or has
324315
a default value.
325316
"""
326317
return self.isSet(param) or self.hasDefault(param)
327318

328-
@since("1.4.0")
329319
def hasParam(self, paramName):
330320
"""
331321
Tests whether this instance contains a param with a given
@@ -337,7 +327,6 @@ def hasParam(self, paramName):
337327
else:
338328
raise TypeError("hasParam(): paramName must be a string")
339329

340-
@since("1.4.0")
341330
def getOrDefault(self, param):
342331
"""
343332
Gets the value of a param in the user-supplied param map or its
@@ -349,7 +338,6 @@ def getOrDefault(self, param):
349338
else:
350339
return self._defaultParamMap[param]
351340

352-
@since("1.4.0")
353341
def extractParamMap(self, extra=None):
354342
"""
355343
Extracts the embedded default param values and user-supplied
@@ -368,7 +356,6 @@ def extractParamMap(self, extra=None):
368356
paramMap.update(extra)
369357
return paramMap
370358

371-
@since("1.4.0")
372359
def copy(self, extra=None):
373360
"""
374361
Creates a copy of this instance with the same uid and some

0 commit comments

Comments
 (0)