LogisticRegressionModel#

class spark_rapids_ml.classification.LogisticRegressionModel(coef_: Union[List[List[float]], List[List[List[float]]]], intercept_: Union[List[float], List[List[float]]], classes_: List[float], n_cols: int, dtype: str, num_iters: int, objective: float)#

Model fitted by LogisticRegression.

Methods

clear(param)

Reset a Spark ML Param to its default value, setting matching cuML parameter, if exists.

copy([extra])

cpu()

Return the PySpark ML LogisticRegressionModel

evaluate(dataset)

cuML doesn't support evaluating.

explainParam(param)

Explains a single param and returns its name, doc, and optional default value and user-supplied value in a string.

explainParams()

Returns the documentation of all params with their optionally default values and user-supplied values.

extractParamMap([extra])

Extracts the embedded default param values and user-supplied values, and then merges them with extra values from input into a flat param map, where the latter value is used if there exist conflicts, i.e., with ordering: default param values < user-supplied values < extra.

getElasticNetParam()

Gets the value of elasticNetParam or its default value.

getFeaturesCol()

Gets the value of featuresCol or featuresCols

getFeaturesCols()

Gets the value of featuresCols or its default value.

getFitIntercept()

Gets the value of fitIntercept or its default value.

getLabelCol()

Gets the value of labelCol or its default value.

getMaxIter()

Gets the value of maxIter or its default value.

getOrDefault(param)

Gets the value of a param in the user-supplied param map or its default value.

getParam(paramName)

Gets a param by its name.

getPredictionCol()

Gets the value of predictionCol or its default value.

getProbabilityCol()

Gets the value of probabilityCol or its default value.

getRawPredictionCol()

Gets the value of rawPredictionCol or its default value.

getRegParam()

Gets the value of regParam or its default value.

getStandardization()

Gets the value of standardization or its default value.

getTol()

Gets the value of tol or its default value.

hasDefault(param)

Checks whether a param has a default value.

hasParam(paramName)

Tests whether this instance contains a param with a given (string) name.

isDefined(param)

Checks whether a param is explicitly set by user or has a default value.

isSet(param)

Checks whether a param is explicitly set by user.

load(path)

Reads an ML instance from the input path, a shortcut of read().load(path).

predict(value)

cuML doesn't support predicting 1 single sample.

predictProbability(value)

Predict the probability of each class given the features.

predictRaw(value)

Raw prediction for each possible label.

read()

save(path)

Save this ML instance to the given path, a shortcut of 'write().save(path)'.

set(param, value)

Sets a parameter in the embedded param map.

setFeaturesCol(value)

Sets the value of featuresCol or featureCols.

setFeaturesCols(value)

Sets the value of featuresCols.

setLabelCol(value)

Sets the value of labelCol.

setPredictionCol(value)

Sets the value of predictionCol.

setProbabilityCol(value)

Sets the value of probabilityCol.

setRawPredictionCol(value)

Sets the value of rawPredictionCol.

transform(dataset[, params])

Transforms the input dataset with optional parameters.

write()

Attributes

coefficientMatrix

Model coefficients.

coefficients

Model coefficients.

cuml_params

Returns the dictionary of parameters intended for the underlying cuML class.

elasticNetParam

enable_sparse_data_optim

featuresCol

featuresCols

fitIntercept

hasSummary

Indicates whether a training summary exists for this model instance.

intercept

Model intercept.

interceptVector

Model intercept.

labelCol

maxIter

numClasses

numFeatures

Returns the number of features the model was trained on.

num_workers

Number of cuML workers, where each cuML worker corresponds to one Spark task running on one GPU.

params

Returns all params ordered by name.

predictionCol

probabilityCol

rawPredictionCol

regParam

standardization

summary

Gets summary (accuracy/precision/recall, objective history, total iterations) of model trained on the training set.

tol

Methods Documentation

clear(param: Param) None#

Reset a Spark ML Param to its default value, setting matching cuML parameter, if exists.

copy(extra: Optional[ParamMap] = None) P#
cpu() LogisticRegressionModel#

Return the PySpark ML LogisticRegressionModel

evaluate(dataset: DataFrame) LogisticRegressionSummary#

cuML doesn’t support evaluating. Fall back to PySpark ML LogisticRegressionModel

explainParam(param: Union[str, Param]) str#

Explains a single param and returns its name, doc, and optional default value and user-supplied value in a string.

explainParams() str#

Returns the documentation of all params with their optionally default values and user-supplied values.

extractParamMap(extra: Optional[ParamMap] = None) ParamMap#

Extracts the embedded default param values and user-supplied values, and then merges them with extra values from input into a flat param map, where the latter value is used if there exist conflicts, i.e., with ordering: default param values < user-supplied values < extra.

Parameters:
extradict, optional

extra param values

Returns:
dict

merged param map

getElasticNetParam() float#

Gets the value of elasticNetParam or its default value.

getFeaturesCol() Union[str, List[str]]#

Gets the value of featuresCol or featuresCols

getFeaturesCols() List[str]#

Gets the value of featuresCols or its default value.

getFitIntercept() bool#

Gets the value of fitIntercept or its default value.

getLabelCol() str#

Gets the value of labelCol or its default value.

getMaxIter() int#

Gets the value of maxIter or its default value.

getOrDefault(param: Union[str, Param[T]]) Union[Any, T]#

Gets the value of a param in the user-supplied param map or its default value. Raises an error if neither is set.

getParam(paramName: str) Param#

Gets a param by its name.

getPredictionCol() str#

Gets the value of predictionCol or its default value.

getProbabilityCol() str#

Gets the value of probabilityCol or its default value.

getRawPredictionCol() str#

Gets the value of rawPredictionCol or its default value.

getRegParam() float#

Gets the value of regParam or its default value.

getStandardization() bool#

Gets the value of standardization or its default value.

getTol() float#

Gets the value of tol or its default value.

hasDefault(param: Union[str, Param[Any]]) bool#

Checks whether a param has a default value.

hasParam(paramName: str) bool#

Tests whether this instance contains a param with a given (string) name.

isDefined(param: Union[str, Param[Any]]) bool#

Checks whether a param is explicitly set by user or has a default value.

isSet(param: Union[str, Param[Any]]) bool#

Checks whether a param is explicitly set by user.

classmethod load(path: str) RL#

Reads an ML instance from the input path, a shortcut of read().load(path).

predict(value: Vector) float#

cuML doesn’t support predicting 1 single sample. Fall back to PySpark ML LogisticRegressionModel

predictProbability(value: Vector) Vector#

Predict the probability of each class given the features. Fall back to PySpark ML LogisticRegressionModel

predictRaw(value: Vector) Vector#

Raw prediction for each possible label. Fall back to PySpark ML LogisticRegressionModel

classmethod read() MLReader#
save(path: str) None#

Save this ML instance to the given path, a shortcut of ‘write().save(path)’.

set(param: Param, value: Any) None#

Sets a parameter in the embedded param map.

setFeaturesCol(value: Union[str, List[str]]) _LogisticRegressionCumlParams#

Sets the value of featuresCol or featureCols.

setFeaturesCols(value: List[str]) _LogisticRegressionCumlParams#

Sets the value of featuresCols.

setLabelCol(value: str) _LogisticRegressionCumlParams#

Sets the value of labelCol.

setPredictionCol(value: str) _LogisticRegressionCumlParams#

Sets the value of predictionCol.

setProbabilityCol(value: str) _LogisticRegressionCumlParams#

Sets the value of probabilityCol.

setRawPredictionCol(value: str) _LogisticRegressionCumlParams#

Sets the value of rawPredictionCol.

transform(dataset: DataFrame, params: Optional[ParamMap] = None) DataFrame#

Transforms the input dataset with optional parameters.

New in version 1.3.0.

Parameters:
datasetpyspark.sql.DataFrame

input dataset

paramsdict, optional

an optional param map that overrides embedded params.

Returns:
pyspark.sql.DataFrame

transformed dataset

write() MLWriter#

Attributes Documentation

coefficientMatrix#

Model coefficients. Note Spark CPU uses denseCoefficientMatrix.compressed that may return a sparse vector if there are many zero values. Since the compressed function is not available in pyspark, Spark Rapids ML always returns a dense vector.

coefficients#

Model coefficients.

cuml_params#

Returns the dictionary of parameters intended for the underlying cuML class.

elasticNetParam: Param[float] = Param(parent='undefined', name='elasticNetParam', doc='the ElasticNet mixing parameter, in range [0, 1]. For alpha = 0, the penalty is an L2 penalty. For alpha = 1, it is an L1 penalty.')#
enable_sparse_data_optim = Param(parent='undefined', name='enable_sparse_data_optim', doc='This param activates sparse data optimization for VectorUDT features column. If the param is not included in an Estimator class, Spark rapids ml always converts VectorUDT features column into dense arrays when calling cuml backend. If included, Spark rapids ml will determine whether to create sparse arrays based on the param value: (1) If None, create dense arrays if the first VectorUDT of a dataframe is DenseVector. Create sparse arrays if it is SparseVector.(2) If False, create dense arrays. This is favorable if the majority of vectors are DenseVector.(3) If True, create sparse arrays. This is favorable if the majority of the VectorUDT vectors are SparseVector.')#
featuresCol: Param[str] = Param(parent='undefined', name='featuresCol', doc='features column name.')#
featuresCols = Param(parent='undefined', name='featuresCols', doc='features column names for multi-column input.')#
fitIntercept: Param[bool] = Param(parent='undefined', name='fitIntercept', doc='whether to fit an intercept term.')#
hasSummary#

Indicates whether a training summary exists for this model instance.

intercept#

Model intercept.

interceptVector#

Model intercept.

labelCol: Param[str] = Param(parent='undefined', name='labelCol', doc='label column name.')#
maxIter: Param[int] = Param(parent='undefined', name='maxIter', doc='max number of iterations (>= 0).')#
numClasses#
numFeatures#

Returns the number of features the model was trained on. If unknown, returns -1

num_workers#

Number of cuML workers, where each cuML worker corresponds to one Spark task running on one GPU.

params#

Returns all params ordered by name. The default implementation uses dir() to get all attributes of type Param.

predictionCol: Param[str] = Param(parent='undefined', name='predictionCol', doc='prediction column name.')#
probabilityCol: Param[str] = Param(parent='undefined', name='probabilityCol', doc='Column name for predicted class conditional probabilities. Note: Not all models output well-calibrated probability estimates! These probabilities should be treated as confidences, not precise probabilities.')#
rawPredictionCol: Param[str] = Param(parent='undefined', name='rawPredictionCol', doc='raw prediction (a.k.a. confidence) column name.')#
regParam: Param[float] = Param(parent='undefined', name='regParam', doc='regularization parameter (>= 0).')#
standardization: Param[bool] = Param(parent='undefined', name='standardization', doc='whether to standardize the training features before fitting the model.')#
summary#

Gets summary (accuracy/precision/recall, objective history, total iterations) of model trained on the training set. An exception is thrown if trainingSummary is None.

tol: Param[float] = Param(parent='undefined', name='tol', doc='the convergence tolerance for iterative algorithms (>= 0).')#