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

    https://github.com/apache/spark/pull/1361#discussion_r15718348
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/regression/StreamingLinearAlgorithm.scala
 ---
    @@ -0,0 +1,83 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.mllib.regression
    +
    +import org.apache.spark.annotation.DeveloperApi
    +import org.apache.spark.Logging
    +import org.apache.spark.streaming.dstream.DStream
    +
    +/**
    + * :: DeveloperApi ::
    --- End diff --
    
    I've been testing this and it seems fairly robust, agreed we should clarify 
in the documentation. 
    
    What I've tried:
    
    - If train and predict are called on the same stream (or on two streams 
with data arriving simultaneously), order matters. If trainOn is first, the 
prediction will always use the subsequently updated model. If predictOn is 
first, it will use the model from the previous update. In practice, over 
multiple updates, either behavior seems reasonable, but maybe there should be a 
helpful warning if the user calls predictOn before trainOn?
    
    - If they are called on different streams and the data arrive sequentially, 
order doesn't matter. For example, if data arrive in the predictOn stream 
before the trainOn stream, the prediction uses the intial weights (as it 
should) to predict, regardless of the order of the calls.
    
    - It's ok, and maybe useful, to call predictOn repeatedly on different 
streams. For example, training on one stream, and predicting on it and another, 
behaves correctly (modolu the ordering issues described above).
    
    - If you call trainOn repeatedly on different streams, it will do an update 
when data arrive in either stream, which seems fine. Could be used to update 
using multiple input sources.


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

Reply via email to