Description

Logistic regression train batch operator. we use log loss func by setting LinearModelType = LR and model name = “Logistic Regression”.

Parameters

Name Description Type Required? Default Value
optimMethod optimization method String null
l1 the L1-regularized parameter. Double 0.0
l2 the L2-regularized parameter. Double 0.0
withIntercept Whether has intercept or not, default is true Boolean true
maxIter Maximum iterations, The default value is 100 Integer 100
epsilon Convergence tolerance for iterative algorithms (>= 0), The default value is 1.0e-06 Double 1.0E-6
featureCols Names of the feature columns used for training in the input table String[] null
labelCol Name of the label column in the input table String
weightCol Name of the column indicating weight String null
vectorCol Name of a vector column String null
standardization Whether standardize training data or not, default is true Boolean true

Script Example

Script

  1. import numpy as np
  2. import pandas as pd
  3. data = np.array([
  4. [2, 1, 1],
  5. [3, 2, 1],
  6. [4, 3, 2],
  7. [2, 4, 1],
  8. [2, 2, 1],
  9. [4, 3, 2],
  10. [1, 2, 1],
  11. [5, 3, 2]])
  12. df = pd.DataFrame({"f0": data[:, 0],
  13. "f1": data[:, 1],
  14. "label": data[:, 2]})
  15. input = dataframeToOperator(df, schemaStr='f0 int, f1 int, label int', op_type='batch')
  16. # load data
  17. dataTest = input
  18. colnames = ["f0","f1"]
  19. lr = LogisticRegressionTrainBatchOp().setFeatureCols(colnames).setLabelCol("label")
  20. model = input.link(lr)
  21. predictor = LogisticRegressionPredictBatchOp().setPredictionCol("pred")
  22. predictor.linkFrom(model, dataTest).print()

Result

f0 f1 label pred
2 1 1 1
3 2 1 1
4 3 2 2
2 4 1 1
2 2 1 1
4 3 2 2
1 2 1 1
5 3 2 2