Github user freeman-lab commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6744#discussion_r33203877
  
    --- Diff: python/pyspark/mllib/regression.py ---
    @@ -570,6 +571,92 @@ def train(cls, data, isotonic=True):
             return IsotonicRegressionModel(boundaries.toArray(), 
predictions.toArray(), isotonic)
     
     
    +@inherit_doc
    +class StreamingLinearRegressionWithSGD(LinearRegressionModel):
    +    """
    +    Run LinearRegression with SGD on a stream of data.
    +
    +    The problem minimized is (1 / n_samples) * (y - weights'X)**2.
    +    After training on a stream of data, the weights obtained at the end of
    +    training are used as initial weights for the next stream of data.
    +
    +    :param: stepSize          Step size for each iteration of gradient
    +                              descent.
    +    :param: numIterations     Total number of iterations run.
    +    :param: miniBatchFraction Fraction of data on which SGD is run for each
    +                              iteration.
    +    """
    +    def __init__(self, stepSize=0.1, numIterations=50, 
miniBatchFraction=1.0):
    +        self.stepSize = stepSize
    +        self.numIterations = numIterations
    +        self.miniBatchFraction = miniBatchFraction
    +        self._model = None
    +
    +    def _validate_dstream(self, dstream):
    +        if not isinstance(dstream, DStream):
    +            raise TypeError(
    +                "dstream should be a DStream object, got %s" % 
type(dstream))
    +        if not self._model:
    +            raise ValueError(
    +                "Model must be intialized using setInitialWeights")
    +
    +    @property
    +    def latestModel(self):
    +        """Returns a LinearRegressionModel fit on the latest stream of 
data.
    +
    +        The weights and intercepts can be got from the `weights` and
    --- End diff --
    
    `got` -> `obtained`


---
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