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

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

destroy()#

Destroy the solver.

Collective.

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

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

getLinearCoefficients()#

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

Not collective.

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

Return type:

Vec

getLinearIntercept()#

Get the intercept from a linear regression model.

Not collective.

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

Return type:

Scalar

getLinearKSP()#

Returns the KSP context used by the linear regressor.

Not collective.

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

Return type:

KSP

getLinearType()#

Return the type of the linear regressor.

Not collective.

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

Return type:

RegressorLinearType

getTAO()#

Return the underlying TAO object .

Not collective.

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

Return type:

TAO

getType()#

Return the type of the solver.

Not collective.

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

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

reset()#

Destroy internal data structures of the solver.

Collective.

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

Return type:

None

setFromOptions()#

Configure the solver from the options database.

Collective.

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.

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.

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.

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.

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

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

setUp()#

Set up the internal data structures for using the solver.

Collective.

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

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