class_docstr: Model for Support Vector Machines (SVMs).
  
  .. versionadded:: 0.9.0
  
  Parameters
  ----------
  weights : :py:class:`pyspark.mllib.linalg.Vector`
      Weights computed for every feature.
  intercept : float
      Intercept computed for this model.
  
  Examples
  --------
  >>> from pyspark.mllib.linalg import SparseVector
  >>> data = [
  ...     LabeledPoint(0.0, [0.0]),
  ...     LabeledPoint(1.0, [1.0]),
  ...     LabeledPoint(1.0, [2.0]),
  ...     LabeledPoint(1.0, [3.0])
  ... ]
  >>> svm = SVMWithSGD.train(sc.parallelize(data), iterations=10)
  >>> svm.predict([1.0])
  1
  >>> svm.predict(sc.parallelize([[1.0]])).collect()
  [1]
  >>> svm.clearThreshold()
  >>> svm.predict(numpy.array([1.0]))
  1.44...
  
  >>> sparse_data = [
  ...     LabeledPoint(0.0, SparseVector(2, {0: -1.0})),
  ...     LabeledPoint(1.0, SparseVector(2, {1: 1.0})),
  ...     LabeledPoint(0.0, SparseVector(2, {0: 0.0})),
  ...     LabeledPoint(1.0, SparseVector(2, {1: 2.0}))
  ... ]
  >>> svm = SVMWithSGD.train(sc.parallelize(sparse_data), iterations=10)
  >>> svm.predict(SparseVector(2, {1: 1.0}))
  1
  >>> svm.predict(SparseVector(2, {0: -1.0}))
  0
  >>> import os, tempfile
  >>> path = tempfile.mkdtemp()
  >>> svm.save(sc, path)
  >>> sameModel = SVMModel.load(sc, path)
  >>> sameModel.predict(SparseVector(2, {1: 1.0}))
  1
  >>> sameModel.predict(SparseVector(2, {0: -1.0}))
  0
  >>> from shutil import rmtree
  >>> try:
  ...    rmtree(path)
  ... except BaseException:
  ...    pass
class_docstr_tok: ["Model","for","Support","Vector","Machines","(","SVMs",")",".","..","versionadded",":",":","0.9.0","Parameters","--","--","--","--","--","weights",":",":","py",":","class",":","`","pyspark.mllib.linalg.Vector","`","Weights","computed","for","every","feature",".","intercept",":","float","Intercept","computed","for","this","model",".","Examples","--","--","--","--",">",">",">","from","pyspark.mllib.linalg","import","SparseVector",">",">",">","data","=","[","...","LabeledPoint","(","0.0",",","[","0.0","]",")",",","...","LabeledPoint","(","1.0",",","[","1.0","]",")",",","...","LabeledPoint","(","1.0",",","[","2.0","]",")",",","...","LabeledPoint","(","1.0",",","[","3.0","]",")","...","]",">",">",">","svm","=","SVMWithSGD.train","(","sc.parallelize","(","data",")",",","iterations=10",")",">",">",">","svm.predict","(","[","1.0","]",")","1",">",">",">","svm.predict","(","sc.parallelize","(","[","[","1.0","]","]",")",")",".collect","(",")","[","1","]",">",">",">","svm.clearThreshold","(",")",">",">",">","svm.predict","(","numpy.array","(","[","1.0","]",")",")","1.44","...",">",">",">","sparse_data","=","[","...","LabeledPoint","(","0.0",",","SparseVector","(","2",",","{","0",":","-1.0","}",")",")",",","...","LabeledPoint","(","1.0",",","SparseVector","(","2",",","{","1",":","1.0","}",")",")",",","...","LabeledPoint","(","0.0",",","SparseVector","(","2",",","{","0",":","0.0","}",")",")",",","...","LabeledPoint","(","1.0",",","SparseVector","(","2",",","{","1",":","2.0","}",")",")","...","]",">",">",">","svm","=","SVMWithSGD.train","(","sc.parallelize","(","sparse_data",")",",","iterations=10",")",">",">",">","svm.predict","(","SparseVector","(","2",",","{","1",":","1.0","}",")",")","1",">",">",">","svm.predict","(","SparseVector","(","2",",","{","0",":","-1.0","}",")",")","0",">",">",">","import","os",",","tempfile",">",">",">","path","=","tempfile.mkdtemp","(",")",">",">",">","svm.save","(","sc",",","path",")",">",">",">","sameModel","=","SVMModel.load","(","sc",",","path",")",">",">",">","sameModel.predict","(","SparseVector","(","2",",","{","1",":","1.0","}",")",")","1",">",">",">","sameModel.predict","(","SparseVector","(","2",",","{","0",":","-1.0","}",")",")","0",">",">",">","from","shutil","import","rmtree",">",">",">","try",":","...","rmtree","(","path",")","...","except","BaseException",":","...","pass"]
docstr: Predict values for a single data point or an RDD of points
  using the model trained.
  
  .. versionadded:: 0.9.0
docstr_tok: ["Predict","values","for","a","single","data","point","or","an","RDD","of","points","using","the","model","trained",".","..","versionadded",":",":","0.9.0"]
code: def predict(
      self, x: Union["VectorLike", RDD["VectorLike"]]
  ) -> Union[RDD[Union[int, float]], Union[int, float]]:
      """
      Predict values for a single data point or an RDD of points
      using the model trained.
  
      .. versionadded:: 0.9.0
      """
      if isinstance(x, RDD):
          return x.map(lambda v: self.predict(v))
  
      x = _convert_to_vector(x)
      margin = self.weights.dot(x) + self.intercept  # type: ignore[attr-defined]
      if self._threshold is None:
          return margin
      else:
          return 1 if margin > self._threshold else 0
  
imports: from math import exp
  import sys
  import warnings
  from typing import Any, Iterable, Optional, Union, overload, TYPE_CHECKING
  import numpy
  from pyspark import RDD, SparkContext, since
  from pyspark.streaming.dstream import DStream
  from pyspark.mllib.common import callMLlibFunc, _py2java, _java2py
  from pyspark.mllib.linalg import _convert_to_vector
  from pyspark.mllib.regression import LabeledPoint, LinearModel, _regression_train_wrapper, StreamingLinearAlgorithm
  from pyspark.mllib.util import Saveable, Loader, inherit_doc
  from pyspark.mllib.linalg import Vector
  from pyspark.mllib.regression import LabeledPoint
label_desc: Use image node_id 4 for calling the SVMModel obj's underlying member method code with example usage: obj.predict(x) and returns: x, margin, unknown