public class StreamingKMeans
extends java.lang.Object
implements 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() |
protected static void |
initializeLogIfNecessary(boolean isInterpreter) |
protected static boolean |
isTraceEnabled() |
int |
k() |
StreamingKMeansModel |
latestModel()
Return the latest model.
|
protected static org.slf4j.Logger |
log() |
protected static void |
logDebug(scala.Function0<java.lang.String> msg) |
protected static void |
logDebug(scala.Function0<java.lang.String> msg,
java.lang.Throwable throwable) |
protected static void |
logError(scala.Function0<java.lang.String> msg) |
protected static void |
logError(scala.Function0<java.lang.String> msg,
java.lang.Throwable throwable) |
protected static void |
logInfo(scala.Function0<java.lang.String> msg) |
protected static void |
logInfo(scala.Function0<java.lang.String> msg,
java.lang.Throwable throwable) |
protected static java.lang.String |
logName() |
protected static void |
logTrace(scala.Function0<java.lang.String> msg) |
protected static void |
logTrace(scala.Function0<java.lang.String> msg,
java.lang.Throwable throwable) |
protected static void |
logWarning(scala.Function0<java.lang.String> msg) |
protected static void |
logWarning(scala.Function0<java.lang.String> msg,
java.lang.Throwable throwable) |
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 forgetfulness of the previous centroids.
|
StreamingKMeans |
setHalfLife(double halfLife,
java.lang.String timeUnit)
Set the half life and time unit ("batches" or "points").
|
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 . |
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()
protected static java.lang.String logName()
protected static org.slf4j.Logger log()
protected static void logInfo(scala.Function0<java.lang.String> msg)
protected static void logDebug(scala.Function0<java.lang.String> msg)
protected static void logTrace(scala.Function0<java.lang.String> msg)
protected static void logWarning(scala.Function0<java.lang.String> msg)
protected static void logError(scala.Function0<java.lang.String> msg)
protected static void logInfo(scala.Function0<java.lang.String> msg, java.lang.Throwable throwable)
protected static void logDebug(scala.Function0<java.lang.String> msg, java.lang.Throwable throwable)
protected static void logTrace(scala.Function0<java.lang.String> msg, java.lang.Throwable throwable)
protected static void logWarning(scala.Function0<java.lang.String> msg, java.lang.Throwable throwable)
protected static void logError(scala.Function0<java.lang.String> msg, java.lang.Throwable throwable)
protected static boolean isTraceEnabled()
protected static void initializeLogIfNecessary(boolean isInterpreter)
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)