TrainRegressor

class TrainRegressor.TrainRegressor(labelCol=None, model=None, numFeatures=0)[source]

Bases: mmlspark.Utils.ComplexParamsMixin, pyspark.ml.util.JavaMLReadable, pyspark.ml.util.JavaMLWritable, pyspark.ml.wrapper.JavaEstimator

Use TrainRegressor to train a regression model on a dataset.

Below is an example that uses TrainRegressor. Given a DataFrame, myDataFrame, with a label column, “MyLabel”, split the DataFrame into train and test sets. Train a regressor on the dataset with a solver, such as l-bfgs:

>>> from mmlspark.TrainRegressor import TrainRegressor
>>> from pysppark.ml.regression import LinearRegression
>>> lr = LinearRegression().setSolver("l-bfgs").setRegParam(0.1).setElasticNetParam(0.3)
>>> model = TrainRegressor(model=lr, labelCol="MyLabel", numFeatures=1 << 18).fit(train)

Now that you have a model, you can score the regressor on the test data:

>>> scoredData = model.transform(test)
Parameters:
  • labelCol (str) – The name of the label column
  • model (object) – Regressor to run
  • numFeatures (int) – Number of features to hash to (default: 0)
static getJavaPackage()[source]

Returns package name String.

getLabelCol()[source]
Returns:The name of the label column
Return type:str
getModel()[source]
Returns:Regressor to run
Return type:object
getNumFeatures()[source]
Returns:Number of features to hash to (default: 0)
Return type:int
classmethod read()[source]

Returns an MLReader instance for this class.

setLabelCol(value)[source]
Parameters:labelCol (str) – The name of the label column
setModel(value)[source]
Parameters:model (object) – Regressor to run
setNumFeatures(value)[source]
Parameters:numFeatures (int) – Number of features to hash to (default: 0)
setParams(labelCol=None, model=None, numFeatures=0)[source]

Set the (keyword only) parameters

Parameters:
  • labelCol (str) – The name of the label column
  • model (object) – Regressor to run
  • numFeatures (int) – Number of features to hash to (default: 0)
class TrainRegressor.TrainedRegressorModel(java_model=None)[source]

Bases: mmlspark.Utils.ComplexParamsMixin, pyspark.ml.wrapper.JavaModel, pyspark.ml.util.JavaMLWritable, pyspark.ml.util.JavaMLReadable

Model fitted by TrainRegressor.

This class is left empty on purpose. All necessary methods are exposed through inheritance.

static getJavaPackage()[source]

Returns package name String.

classmethod read()[source]

Returns an MLReader instance for this class.