Skip to content

Commit

Permalink
change SLR to experimental and update the doc
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxr committed Feb 4, 2015
1 parent ebbb2e9 commit 8aca7ee
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ import scala.reflect.ClassTag

import org.apache.spark.Logging
import org.apache.spark.SparkContext._
import org.apache.spark.annotation.DeveloperApi
import org.apache.spark.annotation.{Experimental, DeveloperApi}
import org.apache.spark.mllib.linalg.{BLAS, Vector, Vectors}
import org.apache.spark.rdd.RDD
import org.apache.spark.streaming.dstream.DStream
import org.apache.spark.util.Utils
import org.apache.spark.util.random.XORShiftRandom

/**
* :: DeveloperApi ::
* :: Experimental ::
*
* StreamingKMeansModel extends MLlib's KMeansModel for streaming
* algorithms, so it can keep track of a continuously updated weight
* associated with each cluster, and also update the model by
Expand All @@ -39,8 +40,10 @@ import org.apache.spark.util.random.XORShiftRandom
* generalized to incorporate forgetfullness (i.e. decay).
* The update rule (for each cluster) is:
*
* {{{
* c_t+1 = [(c_t * n_t * a) + (x_t * m_t)] / [n_t + m_t]
* n_t+t = n_t * a + m_t
* }}}
*
* Where c_t is the previously estimated centroid for that cluster,
* n_t is the number of points assigned to it thus far, x_t is the centroid
Expand All @@ -61,7 +64,7 @@ import org.apache.spark.util.random.XORShiftRandom
* as batches or points.
*
*/
@DeveloperApi
@Experimental
class StreamingKMeansModel(
override val clusterCenters: Array[Vector],
val clusterWeights: Array[Double]) extends KMeansModel(clusterCenters) with Logging {
Expand Down Expand Up @@ -140,7 +143,8 @@ class StreamingKMeansModel(
}

/**
* :: DeveloperApi ::
* :: Experimental ::
*
* StreamingKMeans provides methods for configuring a
* streaming k-means analysis, training the model on streaming,
* and using the model to make predictions on streaming data.
Expand All @@ -149,13 +153,15 @@ class StreamingKMeansModel(
* Use a builder pattern to construct a streaming k-means analysis
* in an application, like:
*
* {{{
* val model = new StreamingKMeans()
* .setDecayFactor(0.5)
* .setK(3)
* .setRandomCenters(5, 100.0)
* .trainOn(DStream)
* }}}
*/
@DeveloperApi
@Experimental
class StreamingKMeans(
var k: Int,
var decayFactor: Double,
Expand Down

0 comments on commit 8aca7ee

Please sign in to comment.