public class KMeans extends Estimator<KMeansModel> implements KMeansParams, DefaultParamsWritable
Modifier and Type | Method and Description |
---|---|
KMeans |
copy(ParamMap extra)
Creates a copy of this instance with the same UID and some extra params.
|
Param<String> |
distanceMeasure()
Param for The distance measure.
|
Param<String> |
featuresCol()
Param for features column name.
|
KMeansModel |
fit(Dataset<?> dataset)
Fits a model to the input data.
|
Param<String> |
initMode()
Param for the initialization algorithm.
|
IntParam |
initSteps()
Param for the number of steps for the k-means|| initialization mode.
|
IntParam |
k()
The number of clusters to create (k).
|
static KMeans |
load(String path) |
IntParam |
maxIter()
Param for maximum number of iterations (>= 0).
|
Param<String> |
predictionCol()
Param for prediction column name.
|
static MLReader<T> |
read() |
LongParam |
seed()
Param for random seed.
|
KMeans |
setDistanceMeasure(String value) |
KMeans |
setFeaturesCol(String value) |
KMeans |
setInitMode(String value) |
KMeans |
setInitSteps(int value) |
KMeans |
setK(int value) |
KMeans |
setMaxIter(int value) |
KMeans |
setPredictionCol(String value) |
KMeans |
setSeed(long value) |
KMeans |
setTol(double value) |
KMeans |
setWeightCol(String value)
Sets the value of param
weightCol . |
DoubleParam |
tol()
Param for the convergence tolerance for iterative algorithms (>= 0).
|
StructType |
transformSchema(StructType schema)
Check transform validity and derive the output schema from the input schema.
|
String |
uid()
An immutable unique ID for the object and its derivatives.
|
Param<String> |
weightCol()
Param for weight column name.
|
params
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getInitMode, getInitSteps, getK, validateAndTransformSchema
getMaxIter
getFeaturesCol
getPredictionCol
getDistanceMeasure
getWeightCol
clear, copyValues, defaultCopy, defaultParamMap, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, paramMap, params, set, set, set, setDefault, setDefault, shouldOwn
toString
write
save
$init$, initializeForcefully, initializeLogIfNecessary, initializeLogIfNecessary, initializeLogIfNecessary$default$2, initLock, isTraceEnabled, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning, org$apache$spark$internal$Logging$$log__$eq, org$apache$spark$internal$Logging$$log_, uninitialize
public static KMeans load(String path)
public static MLReader<T> read()
public final IntParam k()
KMeansParams
k
in interface KMeansParams
public final Param<String> initMode()
KMeansParams
initMode
in interface KMeansParams
public final IntParam initSteps()
KMeansParams
initSteps
in interface KMeansParams
public final Param<String> weightCol()
HasWeightCol
weightCol
in interface HasWeightCol
public final Param<String> distanceMeasure()
HasDistanceMeasure
distanceMeasure
in interface HasDistanceMeasure
public final DoubleParam tol()
HasTol
public final Param<String> predictionCol()
HasPredictionCol
predictionCol
in interface HasPredictionCol
public final LongParam seed()
HasSeed
public final Param<String> featuresCol()
HasFeaturesCol
featuresCol
in interface HasFeaturesCol
public final IntParam maxIter()
HasMaxIter
maxIter
in interface HasMaxIter
public String uid()
Identifiable
uid
in interface Identifiable
public KMeans copy(ParamMap extra)
Params
defaultCopy()
.copy
in interface Params
copy
in class Estimator<KMeansModel>
extra
- (undocumented)public KMeans setFeaturesCol(String value)
public KMeans setPredictionCol(String value)
public KMeans setK(int value)
public KMeans setInitMode(String value)
public KMeans setDistanceMeasure(String value)
public KMeans setInitSteps(int value)
public KMeans setMaxIter(int value)
public KMeans setTol(double value)
public KMeans setSeed(long value)
public KMeans setWeightCol(String value)
weightCol
.
If this is not set or empty, we treat all instance weights as 1.0.
Default is not set, so all instances have weight one.
value
- (undocumented)public KMeansModel fit(Dataset<?> dataset)
Estimator
fit
in class Estimator<KMeansModel>
dataset
- (undocumented)public StructType transformSchema(StructType schema)
PipelineStage
We check validity for interactions between parameters during transformSchema
and
raise an exception if any parameter value is invalid. Parameter value checks which
do not depend on other parameters are handled by Param.validate()
.
Typical implementation should first conduct verification on schema change and parameter validity, including complex parameter interaction checks.
transformSchema
in class PipelineStage
schema
- (undocumented)