Skip to main content
`Ctrl`+`K`

# petsc4py.PETSc.Regressor

class petsc4py.PETSc.Regressor

  Bases: `Object`

  Regression solver.

  REGRESSOR is described in the `PETSc manual`.

  See also

  `PetscRegressor`

  Enumerations

  `LinearType` | Linear regressor type.
  `Type` | REGRESSOR solver type.

  Methods Summary

  `create`([comm]) | Create a REGRESSOR solver.
  `destroy`() | Destroy the solver.
  `fit`(X, y) | Fit the regression problem.
  `getLinearCoefficients`() | Get a vector of the fitted coefficients from a linear regression model.
  `getLinearIntercept`() | Get the intercept from a linear regression model.
  `getLinearKSP`() | Returns the `KSP` context used by the linear regressor.
  `getLinearType`() | Return the type of the linear regressor.
  `getTAO`() | Return the underlying `TAO` object .
  `getType`() | Return the type of the solver.
  `predict`(X, y) | Predict the regression problem.
  `reset`() | Destroy internal data structures of the solver.
  `setFromOptions`() | Configure the solver from the options database.
  `setLinearFitIntercept`(flag) | Set a flag to indicate that the intercept should be calculated.
  `setLinearType`(lineartype) | Set the type of linear regression to be performed.
  `setLinearUseKSP`(flag) | Set a flag to indicate that `KSP` instead of `TAO` solvers should be used.
  `setRegularizerWeight`(weight) | Set the weight to be used for the regularizer.
  `setType`(regressor_type) | Set the type of the solver.
  `setUp`() | Set up the internal data structures for using the solver.
  `view`([viewer]) | View the solver.

  Methods Documentation

  create(comm=None)

    Create a REGRESSOR solver.

    Collective.

    Parameters:

      comm – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      Self

    See also

    `Sys.getDefaultComm`, `PetscRegressorCreate`

    Source code at petsc4py/PETSc/Regressor.pyx:61

  destroy()

    Destroy the solver.

    Collective.

    See also

    `PetscRegressorDestroy`

    Source code at petsc4py/PETSc/Regressor.pyx:180

    Return type:

      Self

  fit(X, y)

    Fit the regression problem.

    Collective.

    Parameters:

      - X (Mat) – The matrix of training data

      - y (Vec) – The vector of target values from the training dataset

    Return type:

      None

    See also

    `PetscRegressorPredict`

    Source code at petsc4py/PETSc/Regressor.pyx:116

  getLinearCoefficients()

    Get a vector of the fitted coefficients from a linear regression model.

    Not collective.

    See also

    `getLinearIntercept`, `PetscRegressorLinearGetCoefficients`

    Source code at petsc4py/PETSc/Regressor.pyx:266

    Return type:

      Vec

  getLinearIntercept()

    Get the intercept from a linear regression model.

    Not collective.

    See also

    `setLinearFitIntercept`, `PetscRegressorLinearGetIntercept`

    Source code at petsc4py/PETSc/Regressor.pyx:280

    Return type:

      Scalar

  getLinearKSP()

    Returns the `KSP` context used by the linear regressor.

    Not collective.

    See also

    `PetscRegressorLinearGetKSP`

    Source code at petsc4py/PETSc/Regressor.pyx:252

    Return type:

      KSP

  getLinearType()

    Return the type of the linear regressor.

    Not collective.

    See also

    `setLinearType`, `PetscRegressorLinearGetType`

    Source code at petsc4py/PETSc/Regressor.pyx:304

    Return type:

      RegressorLinearType

  getTAO()

    Return the underlying `TAO` object .

    Not collective.

    See also

    `getLinearKSP`, `PetscRegressorGetTao`

    Source code at petsc4py/PETSc/Regressor.pyx:154

    Return type:

      TAO

  getType()

    Return the type of the solver.

    Not collective.

    See also

    `setType`, `PetscRegressorGetType`

    Source code at petsc4py/PETSc/Regressor.pyx:212

    Return type:

      str

  predict(X, y)

    Predict the regression problem.

    Collective.

    Parameters:

      - X (Mat) – The matrix of unlabeled observations

      - y (Vec) – The vector of predicted labels

    Return type:

      None

    See also

    `PetscRegressorFit`

    Source code at petsc4py/PETSc/Regressor.pyx:135

  reset()

    Destroy internal data structures of the solver.

    Collective.

    See also

    `PetscRegressorDestroy`

    Source code at petsc4py/PETSc/Regressor.pyx:168

    Return type:

      None

  setFromOptions()

    Configure the solver from the options database.

    Collective.

    See also

    Working with PETSc options, `PetscRegressorSetFromOptions`

    Source code at petsc4py/PETSc/Regressor.pyx:93

    Return type:

      None

  setLinearFitIntercept(flag)

    Set a flag to indicate that the intercept should be calculated.

    Logically collective.

    See also

    `PetscRegressorLinearSetFitIntercept`

    Source code at petsc4py/PETSc/Regressor.pyx:228

    Parameters:

      flag (bool)

    Return type:

      None

  setLinearType(lineartype)

    Set the type of linear regression to be performed.

    Logically collective.

    See also

    `getLinearType`, `PetscRegressorLinearSetType`

    Source code at petsc4py/PETSc/Regressor.pyx:293

    Parameters:

      lineartype (RegressorLinearType)

    Return type:

      None

  setLinearUseKSP(flag)

    Set a flag to indicate that `KSP` instead of `TAO` solvers should be used.

    Logically collective.

    See also

    `PetscRegressorLinearSetUseKSP`

    Source code at petsc4py/PETSc/Regressor.pyx:240

    Parameters:

      flag (bool)

    Return type:

      None

  setRegularizerWeight(weight)

    Set the weight to be used for the regularizer.

    Logically collective.

    See also

    `setType`, `PetscRegressorSetRegularizerWeight`

    Source code at petsc4py/PETSc/Regressor.pyx:82

    Parameters:

      weight (float)

    Return type:

      None

  setType(regressor_type)

    Set the type of the solver.

    Logically collective.

    Parameters:

      regressor_type (Type | str) – The type of the solver.

    Return type:

      None

    See also

    `getType`, `PetscRegressorSetType`

    Source code at petsc4py/PETSc/Regressor.pyx:193

  setUp()

    Set up the internal data structures for using the solver.

    Collective.

    See also

    `PetscRegressorSetUp`

    Source code at petsc4py/PETSc/Regressor.pyx:104

    Return type:

      None

  view(viewer=None)

    View the solver.

    Collective.

    Parameters:

      viewer (Viewer | None) – A `Viewer` instance or `None` for the default viewer.

    Return type:

      None

    See also

    `PetscRegressorView`

    Source code at petsc4py/PETSc/Regressor.pyx:42

  __init__()
  classmethod __new__(*args, **kwargs)