public class NaiveBayesModel extends ProbabilisticClassificationModel<Vector,NaiveBayesModel> implements MLWritable
NaiveBayes
param: pi log of class priors, whose dimension is C (number of classes)
param: theta log of class conditional probabilities, whose dimension is C (number of classes)
by D (number of features)Modifier and Type | Method and Description |
---|---|
static Params |
clear(Param<?> param) |
NaiveBayesModel |
copy(ParamMap extra)
Creates a copy of this instance with the same UID and some extra params.
|
static String |
explainParam(Param<?> param) |
static String |
explainParams() |
static ParamMap |
extractParamMap() |
static ParamMap |
extractParamMap(ParamMap extra) |
static Param<String> |
featuresCol() |
static <T> scala.Option<T> |
get(Param<T> param) |
static <T> scala.Option<T> |
getDefault(Param<T> param) |
static String |
getFeaturesCol() |
static String |
getLabelCol() |
static String |
getModelType() |
String |
getModelType() |
static <T> T |
getOrDefault(Param<T> param) |
static Param<Object> |
getParam(String paramName) |
static String |
getPredictionCol() |
static String |
getProbabilityCol() |
static String |
getRawPredictionCol() |
static double |
getSmoothing() |
double |
getSmoothing() |
static double[] |
getThresholds() |
static String |
getWeightCol() |
static <T> boolean |
hasDefault(Param<T> param) |
static boolean |
hasParam(String paramName) |
static boolean |
hasParent() |
static boolean |
isDefined(Param<?> param) |
static boolean |
isSet(Param<?> param) |
static Param<String> |
labelCol() |
static NaiveBayesModel |
load(String path) |
static Param<String> |
modelType() |
Param<String> |
modelType()
The model type which is a string (case-sensitive).
|
int |
numClasses() |
int |
numFeatures() |
static Param<?>[] |
params() |
static void |
parent_$eq(Estimator<M> x$1) |
static Estimator<M> |
parent() |
Vector |
pi() |
static Param<String> |
predictionCol() |
static Param<String> |
probabilityCol() |
static Param<String> |
rawPredictionCol() |
static MLReader<NaiveBayesModel> |
read() |
static void |
save(String path) |
static <T> Params |
set(Param<T> param,
T value) |
static M |
setFeaturesCol(String value) |
static M |
setParent(Estimator<M> parent) |
static M |
setPredictionCol(String value) |
static M |
setProbabilityCol(String value) |
static M |
setRawPredictionCol(String value) |
static M |
setThresholds(double[] value) |
static DoubleParam |
smoothing() |
DoubleParam |
smoothing()
The smoothing parameter.
|
Matrix |
theta() |
static DoubleArrayParam |
thresholds() |
String |
toString() |
static Dataset<Row> |
transform(Dataset<?> dataset) |
static Dataset<Row> |
transform(Dataset<?> dataset,
ParamMap paramMap) |
static Dataset<Row> |
transform(Dataset<?> dataset,
ParamPair<?> firstParamPair,
ParamPair<?>... otherParamPairs) |
static Dataset<Row> |
transform(Dataset<?> dataset,
ParamPair<?> firstParamPair,
scala.collection.Seq<ParamPair<?>> otherParamPairs) |
static StructType |
transformSchema(StructType schema) |
String |
uid()
An immutable unique ID for the object and its derivatives.
|
StructType |
validateAndTransformSchema(StructType schema,
boolean fitting,
DataType featuresDataType) |
StructType |
validateAndTransformSchema(StructType schema,
boolean fitting,
DataType featuresDataType)
Validates and transforms the input schema with the provided param map.
|
static Param<String> |
weightCol() |
MLWriter |
write()
Returns an
MLWriter instance for this ML instance. |
normalizeToProbabilitiesInPlace, setProbabilityCol, setThresholds, transform
setRawPredictionCol
setFeaturesCol, setPredictionCol, transformSchema
transform, transform, transform
getWeightCol, weightCol
clear, copyValues, defaultCopy, defaultParamMap, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, paramMap, params, set, set, set, setDefault, setDefault, shouldOwn
save
getRawPredictionCol, rawPredictionCol
getProbabilityCol, probabilityCol
getThresholds, thresholds
getLabelCol, labelCol
featuresCol, getFeaturesCol
getPredictionCol, predictionCol
initializeLogging, initializeLogIfNecessary, initializeLogIfNecessary, isTraceEnabled, log_, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning
public static MLReader<NaiveBayesModel> read()
public static NaiveBayesModel load(String path)
public static Param<?>[] params()
public static String explainParam(Param<?> param)
public static String explainParams()
public static final boolean isSet(Param<?> param)
public static final boolean isDefined(Param<?> param)
public static boolean hasParam(String paramName)
public static Param<Object> getParam(String paramName)
public static final <T> scala.Option<T> get(Param<T> param)
public static final <T> T getOrDefault(Param<T> param)
public static final <T> scala.Option<T> getDefault(Param<T> param)
public static final <T> boolean hasDefault(Param<T> param)
public static final ParamMap extractParamMap()
public static Dataset<Row> transform(Dataset<?> dataset, ParamPair<?> firstParamPair, scala.collection.Seq<ParamPair<?>> otherParamPairs)
public static Dataset<Row> transform(Dataset<?> dataset, ParamPair<?> firstParamPair, ParamPair<?>... otherParamPairs)
public static Estimator<M> parent()
public static void parent_$eq(Estimator<M> x$1)
public static M setParent(Estimator<M> parent)
public static boolean hasParent()
public static final Param<String> labelCol()
public static final String getLabelCol()
public static final Param<String> featuresCol()
public static final String getFeaturesCol()
public static final Param<String> predictionCol()
public static final String getPredictionCol()
public static M setFeaturesCol(String value)
public static M setPredictionCol(String value)
public static StructType transformSchema(StructType schema)
public static final Param<String> rawPredictionCol()
public static final String getRawPredictionCol()
public static M setRawPredictionCol(String value)
public static final Param<String> probabilityCol()
public static final String getProbabilityCol()
public static final DoubleArrayParam thresholds()
public static double[] getThresholds()
public static M setProbabilityCol(String value)
public static M setThresholds(double[] value)
public static final Param<String> weightCol()
public static final String getWeightCol()
public static final DoubleParam smoothing()
public static final double getSmoothing()
public static final Param<String> modelType()
public static final String getModelType()
public static void save(String path) throws java.io.IOException
java.io.IOException
public String uid()
Identifiable
uid
in interface Identifiable
uid
in class ProbabilisticClassificationModel<Vector,NaiveBayesModel>
public Vector pi()
public Matrix theta()
public int numFeatures()
numFeatures
in class ProbabilisticClassificationModel<Vector,NaiveBayesModel>
public int numClasses()
numClasses
in class ProbabilisticClassificationModel<Vector,NaiveBayesModel>
public NaiveBayesModel copy(ParamMap extra)
Params
defaultCopy()
.copy
in interface Params
copy
in class ProbabilisticClassificationModel<Vector,NaiveBayesModel>
extra
- (undocumented)public String toString()
toString
in interface Identifiable
toString
in class ProbabilisticClassificationModel<Vector,NaiveBayesModel>
public MLWriter write()
MLWritable
MLWriter
instance for this ML instance.write
in interface MLWritable
public DoubleParam smoothing()
public double getSmoothing()
public Param<String> modelType()
public String getModelType()
public StructType validateAndTransformSchema(StructType schema, boolean fitting, DataType featuresDataType)
public StructType validateAndTransformSchema(StructType schema, boolean fitting, DataType featuresDataType)
schema
- input schemafitting
- whether this is in fittingfeaturesDataType
- SQL DataType for FeaturesType.
E.g., VectorUDT
for vector features.