public class StreamingKMeans extends java.lang.Object implements Logging, scala.Serializable
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)
Constructor and Description |
---|
StreamingKMeans() |
StreamingKMeans(int k,
double decayFactor,
java.lang.String timeUnit) |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
BATCHES() |
double |
decayFactor() |
int |
k() |
StreamingKMeansModel |
latestModel()
Return the latest model.
|
protected StreamingKMeansModel |
model() |
static java.lang.String |
POINTS() |
DStream<java.lang.Object> |
predictOn(DStream<Vector> data)
Use the clustering model to make predictions on batches of data from a DStream.
|
JavaDStream<java.lang.Integer> |
predictOn(JavaDStream<Vector> data)
Java-friendly version of
predictOn . |
<K> DStream<scala.Tuple2<K,java.lang.Object>> |
predictOnValues(DStream<scala.Tuple2<K,Vector>> data,
scala.reflect.ClassTag<K> evidence$1)
Use the model to make predictions on the values of a DStream and carry over its keys.
|
<K> JavaPairDStream<K,java.lang.Integer> |
predictOnValues(JavaPairDStream<K,Vector> data)
Java-friendly version of
predictOnValues . |
StreamingKMeans |
setDecayFactor(double a)
Set the decay factor directly (for forgetful algorithms).
|
StreamingKMeans |
setHalfLife(double halfLife,
java.lang.String timeUnit)
Set the half life and time unit ("batches" or "points") for forgetful algorithms.
|
StreamingKMeans |
setInitialCenters(Vector[] centers,
double[] weights)
Specify initial centers directly.
|
StreamingKMeans |
setK(int k)
Set the number of clusters.
|
StreamingKMeans |
setRandomCenters(int dim,
double weight,
long seed)
Initialize random centers, requiring only the number of dimensions.
|
java.lang.String |
timeUnit() |
void |
trainOn(DStream<Vector> data)
Update the clustering model by training on batches of data from a DStream.
|
void |
trainOn(JavaDStream<Vector> data)
Java-friendly version of
trainOn . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initializeIfNecessary, initializeLogging, isTraceEnabled, log_, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning
public StreamingKMeans(int k, double decayFactor, java.lang.String timeUnit)
public StreamingKMeans()
public static final java.lang.String BATCHES()
public static final java.lang.String POINTS()
public int k()
public double decayFactor()
public java.lang.String timeUnit()
protected StreamingKMeansModel model()
public StreamingKMeans setK(int k)
k
- (undocumented)public StreamingKMeans setDecayFactor(double a)
a
- (undocumented)public StreamingKMeans setHalfLife(double halfLife, java.lang.String timeUnit)
halfLife
- (undocumented)timeUnit
- (undocumented)public StreamingKMeans setInitialCenters(Vector[] centers, double[] weights)
centers
- (undocumented)weights
- (undocumented)public StreamingKMeans setRandomCenters(int dim, double weight, long seed)
dim
- Number of dimensionsweight
- Weight for each centerseed
- Random seedpublic StreamingKMeansModel latestModel()
public void trainOn(DStream<Vector> data)
data
- DStream containing vector datapublic void trainOn(JavaDStream<Vector> data)
trainOn
.data
- (undocumented)public DStream<java.lang.Object> predictOn(DStream<Vector> data)
data
- DStream containing vector datapublic JavaDStream<java.lang.Integer> predictOn(JavaDStream<Vector> data)
predictOn
.data
- (undocumented)public <K> DStream<scala.Tuple2<K,java.lang.Object>> predictOnValues(DStream<scala.Tuple2<K,Vector>> data, scala.reflect.ClassTag<K> evidence$1)
data
- DStream containing (key, feature vector) pairsevidence$1
- (undocumented)public <K> JavaPairDStream<K,java.lang.Integer> predictOnValues(JavaPairDStream<K,Vector> data)
predictOnValues
.data
- (undocumented)