xref: /petsc/include/petsc/private/regressorimpl.h (revision c12c126234ed623246a63bfa78c9f75a3aa00323)
1 #pragma once
2 
3 #include <petscregressor.h>
4 #include <petsc/private/petscimpl.h>
5 
6 PETSC_EXTERN PetscBool      PetscRegressorRegisterAllCalled;
7 PETSC_EXTERN PetscErrorCode PetscRegressorRegisterAll(void);
8 
9 typedef struct _PetscRegressorOps *PetscRegressorOps;
10 
11 struct _PetscRegressorOps {
12   PetscErrorCode (*setup)(PetscRegressor);
13   PetscErrorCode (*setfromoptions)(PetscRegressor, PetscOptionItems); /* sets options from database */
14   PetscErrorCode (*settraining)(PetscRegressor, Mat, Vec);            /* set the training data matrix and targets */
15   PetscErrorCode (*fit)(PetscRegressor);                              /* compute the transformation to be applied */
16   PetscErrorCode (*predict)(PetscRegressor, Mat, Vec);                /* predict using fitted model */
17   PetscErrorCode (*destroy)(PetscRegressor);
18   PetscErrorCode (*reset)(PetscRegressor);
19   PetscErrorCode (*view)(PetscRegressor, PetscViewer);
20 };
21 
22 /* Define the PetscRegressor data structure. */
23 struct _p_PetscRegressor {
24   PETSCHEADER(struct _PetscRegressorOps);
25 
26   PetscBool setupcalled; /* True if setup has been called */
27   PetscBool fitcalled;   /* True if the Fit() method has been called. */
28   void     *data;        /* Implementation-specific data */
29   Mat       training;    /* Matrix holding the training data set */
30   Vec       target;      /* Targets for training data (response variables or labels) */
31   Tao       tao;         /* Tao optimizer used by many regressor implementations */
32   PetscObjectParameterDeclare(PetscReal, regularizer_weight);
33 };
34 
35 PETSC_EXTERN PetscLogEvent PetscRegressor_SetUp;
36 PETSC_EXTERN PetscLogEvent PetscRegressor_Fit;
37 PETSC_EXTERN PetscLogEvent PetscRegressor_Predict;
38