File: petscregressor.h.html

package info (click to toggle)
petsc 3.24.1%2Bdfsg1-1exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 524,004 kB
  • sloc: ansic: 762,842; cpp: 52,564; python: 39,546; f90: 17,688; javascript: 3,493; makefile: 3,206; sh: 1,508; xml: 619; objc: 445; java: 13; csh: 1
file content (118 lines) | stat: -rw-r--r-- 18,936 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<center><a href="https://gitlab.com/petsc/petsc/-/blob/b522cb8c110832b61be366220eb7433134308289/include/petscregressor.h">Actual source code: petscregressor.h</a></center><br>

<html>
<head>
<title></title>
<meta name="generator" content="c2html 0.9.6">
<meta name="date" content="2025-10-29T18:33:44+00:00">
</head>

<body bgcolor="#FFFFFF">
<pre width=80>
<a name="line1">  1: </a><font color="#A020F0">#pragma once</font>

<a name="line3">  3: </a>#include <A href="../include/petsctao.h.html">&lt;petsctao.h&gt;</A>

<a name="line5">  5: </a><font color="#B22222">/* MANSEC = ML */</font>
<a name="line6">  6: </a><font color="#B22222">/* SUBMANSEC = <a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a> */</font>

<a name="line8">  8: </a><font color="#B22222">/*S</font>
<a name="line9">  9: </a><font color="#B22222">   <a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a> - Abstract PETSc object that manages regression and classification problems</font>

<a name="line11"> 11: </a><font color="#B22222">   Level: beginner</font>

<a name="line13"> 13: </a><font color="#B22222">   Notes:</font>
<a name="line14"> 14: </a><font color="#B22222">   For linear problems `<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>` supports ordinary least squares, lasso, and ridge regression using the `<a href="../manualpages/PetscRegressor/PetscRegressorType.html">PetscRegressorType</a>` of `<a href="../manualpages/PetscRegressor/PETSCREGRESSORLINEAR.html">PETSCREGRESSORLINEAR</a>`</font>
<a name="line15"> 15: </a><font color="#B22222">   and `<a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">PetscRegressorLinearType</a>` of `<a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">REGRESSOR_LINEAR_OLS</a>`, `<a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">REGRESSOR_LINEAR_LASSO</a>`, and `<a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">REGRESSOR_LINEAR_RIDGE</a>`.</font>

<a name="line17"> 17: </a><font color="#B22222">   We have slightly abused the term "regressor" in the naming of this component of PETSc.</font>
<a name="line18"> 18: </a><font color="#B22222">   Statisticians would say that we are doing "regression", and a "regressor", in this context, strictly means an</font>
<a name="line19"> 19: </a><font color="#B22222">   independent (or "predictor") variable in the regression analysis. However, "regressor" has taken on an informal</font>
<a name="line20"> 20: </a><font color="#B22222">   meaning in the machine-learning community of something along the lines of "algorithm or implementation used to fit</font>
<a name="line21"> 21: </a><font color="#B22222">   a regression model". Examples are `MLPRegressor` (multi-layer perceptron regressor) or `RandomForestRegressor`</font>
<a name="line22"> 22: </a><font color="#B22222">   from the scikit-learn toolkit (which is itself not consistent about the use of the term "regressor", since it has a</font>
<a name="line23"> 23: </a><font color="#B22222">   `LinearRegression` component instead of a `LinearRegressor` component).</font>

<a name="line25"> 25: </a><font color="#B22222">.seealso: `<a href="../manualpages/PetscRegressor/PetscRegressorCreate.html">PetscRegressorCreate</a>()`, `<a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">PetscRegressorLinearType</a>`, `<a href="../manualpages/PetscRegressor/PetscRegressorSetType.html">PetscRegressorSetType</a>()`, `<a href="../manualpages/PetscRegressor/PetscRegressorType.html">PetscRegressorType</a>`, `<a href="../manualpages/PetscRegressor/PetscRegressorDestroy.html">PetscRegressorDestroy</a>()`,</font>
<a name="line26"> 26: </a><font color="#B22222">          `<a href="../manualpages/PetscRegressor/PETSCREGRESSORLINEAR.html">PETSCREGRESSORLINEAR</a>`, `<a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">PetscRegressorLinearType</a>`, `<a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">REGRESSOR_LINEAR_OLS</a>`, `<a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">REGRESSOR_LINEAR_LASSO</a>`, `<a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">REGRESSOR_LINEAR_RIDGE</a>`.</font>
<a name="line27"> 27: </a><font color="#B22222">S*/</font>
<a name="line28"> 28: </a><font color="#4169E1">typedef struct _p_PetscRegressor *<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>;</font>

<a name="line30"> 30: </a><font color="#B22222">/*J</font>
<a name="line31"> 31: </a><font color="#B22222">  <a href="../manualpages/PetscRegressor/PetscRegressorType.html">PetscRegressorType</a> - String with the name of a PETSc regression method.</font>

<a name="line33"> 33: </a><font color="#B22222">  Level: beginner</font>

<a name="line35"> 35: </a><font color="#B22222">.seealso: [](ch_regressor), `<a href="../manualpages/PetscRegressor/PetscRegressorSetType.html">PetscRegressorSetType</a>()`, `<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>`, `<a href="../manualpages/PetscRegressor/PetscRegressorRegister.html">PetscRegressorRegister</a>()`, `<a href="../manualpages/PetscRegressor/PetscRegressorCreate.html">PetscRegressorCreate</a>()`, `<a href="../manualpages/PetscRegressor/PetscRegressorSetFromOptions.html">PetscRegressorSetFromOptions</a>()`,</font>
<a name="line36"> 36: </a><font color="#B22222">          `<a href="../manualpages/PetscRegressor/PETSCREGRESSORLINEAR.html">PETSCREGRESSORLINEAR</a>`</font>
<a name="line37"> 37: </a><font color="#B22222">J*/</font>
<a name="line38"> 38: </a><font color="#4169E1">typedef const char *<a href="../manualpages/PetscRegressor/PetscRegressorType.html">PetscRegressorType</a>;</font>
<a name="line39"> 39: </a><strong><font color="#228B22">#define <a href="../manualpages/PetscRegressor/PETSCREGRESSORLINEAR.html">PETSCREGRESSORLINEAR</a> </font><font color="#666666">"linear"</font><font color="#228B22"></font></strong>

<a name="line41"> 41: </a><font color="#B22222">/*E</font>
<a name="line42"> 42: </a><font color="#B22222">  <a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">PetscRegressorLinearType</a> - Type of linear regression</font>

<a name="line44"> 44: </a><font color="#B22222">  Values:</font>
<a name="line45"> 45: </a><font color="#B22222">+  `<a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">REGRESSOR_LINEAR_OLS</a>`    - ordinary least squares</font>
<a name="line46"> 46: </a><font color="#B22222">.  `<a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">REGRESSOR_LINEAR_LASSO</a>`  - lasso</font>
<a name="line47"> 47: </a><font color="#B22222">-  `<a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">REGRESSOR_LINEAR_RIDGE</a>`  - ridge</font>

<a name="line49"> 49: </a><font color="#B22222">  Level: advanced</font>

<a name="line51"> 51: </a><font color="#B22222">  Note:</font>
<a name="line52"> 52: </a><font color="#B22222">  One can perform binary classification using the ridge regressor type by converting labels into the</font>
<a name="line53"> 53: </a><font color="#B22222">  values -1 and +1, corresponding to the two classes, and then performing a ridge regression.</font>
<a name="line54"> 54: </a><font color="#B22222">  Observations with a negative prediction value are then placed in the -1 class, while those with positive values</font>
<a name="line55"> 55: </a><font color="#B22222">  are placed in the +1 class.</font>
<a name="line56"> 56: </a><font color="#B22222">  This is the approach used in the RidgeClassifer implementation provided by the scikit-learn library.</font>

<a name="line58"> 58: </a><font color="#B22222">.seealso: `<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>`, `<a href="../manualpages/PetscRegressor/PETSCREGRESSORLINEAR.html">PETSCREGRESSORLINEAR</a>`</font>
<a name="line59"> 59: </a><font color="#B22222">E*/</font>

<a name="line61"> 61: </a><font color="#4169E1">typedef</font> <font color="#4169E1">enum</font> {
<a name="line62"> 62: </a>  <a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">REGRESSOR_LINEAR_OLS</a>,
<a name="line63"> 63: </a>  <a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">REGRESSOR_LINEAR_LASSO</a>,
<a name="line64"> 64: </a>  <a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">REGRESSOR_LINEAR_RIDGE</a>
<a name="line65"> 65: </a>} <a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">PetscRegressorLinearType</a>;
<a name="line66"> 66: </a>PETSC_EXTERN const char *const PetscRegressorLinearTypes[];

<a name="line68"> 68: </a>PETSC_EXTERN <a href="../manualpages/Sys/PetscFunctionList.html">PetscFunctionList</a> PetscRegressorList;
<a name="line69"> 69: </a>PETSC_EXTERN <a href="../manualpages/Sys/PetscClassId.html">PetscClassId</a>      PETSCREGRESSOR_CLASSID;

<a name="line71"> 71: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorInitializePackage.html">PetscRegressorInitializePackage</a>(void)</font></strong>;
<a name="line72"> 72: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorFinalizePackage.html">PetscRegressorFinalizePackage</a>(void)</font></strong>;
<a name="line73"> 73: </a><strong><font color="#4169E1"><a name="PetscRegressorRegister"></a>PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorRegister.html">PetscRegressorRegister</a>(const char[], <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> (*)(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>)</font></strong>);

<a name="line75"> 75: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorCreate.html">PetscRegressorCreate</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a>, <a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a> *)</font></strong>;
<a name="line76"> 76: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorReset.html">PetscRegressorReset</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>)</font></strong>;
<a name="line77"> 77: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorDestroy.html">PetscRegressorDestroy</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a> *)</font></strong>;

<a name="line79"> 79: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorSetOptionsPrefix.html">PetscRegressorSetOptionsPrefix</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, const char[])</font></strong>;
<a name="line80"> 80: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorAppendOptionsPrefix.html">PetscRegressorAppendOptionsPrefix</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, const char[])</font></strong>;
<a name="line81"> 81: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorGetOptionsPrefix.html">PetscRegressorGetOptionsPrefix</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, const char *[])</font></strong>;

<a name="line83"> 83: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorSetType.html">PetscRegressorSetType</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, <a href="../manualpages/PetscRegressor/PetscRegressorType.html">PetscRegressorType</a>)</font></strong>;
<a name="line84"> 84: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorGetType.html">PetscRegressorGetType</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, <a href="../manualpages/PetscRegressor/PetscRegressorType.html">PetscRegressorType</a> *)</font></strong>;
<a name="line85"> 85: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorSetRegularizerWeight.html">PetscRegressorSetRegularizerWeight</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, <a href="../manualpages/Sys/PetscReal.html">PetscReal</a>)</font></strong>;
<a name="line86"> 86: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorSetUp.html">PetscRegressorSetUp</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>)</font></strong>;
<a name="line87"> 87: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorSetFromOptions.html">PetscRegressorSetFromOptions</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>)</font></strong>;

<a name="line89"> 89: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorView.html">PetscRegressorView</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, <a href="../manualpages/Viewer/PetscViewer.html">PetscViewer</a>)</font></strong>;
<a name="line90"> 90: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorViewFromOptions.html">PetscRegressorViewFromOptions</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, <a href="../manualpages/Sys/PetscObject.html">PetscObject</a>, const char[])</font></strong>;

<a name="line92"> 92: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorFit.html">PetscRegressorFit</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, <a href="../manualpages/Mat/Mat.html">Mat</a>, <a href="../manualpages/Vec/Vec.html">Vec</a>)</font></strong>;
<a name="line93"> 93: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorPredict.html">PetscRegressorPredict</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, <a href="../manualpages/Mat/Mat.html">Mat</a>, <a href="../manualpages/Vec/Vec.html">Vec</a>)</font></strong>;
<a name="line94"> 94: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorGetTao.html">PetscRegressorGetTao</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, <a href="../manualpages/Tao/Tao.html">Tao</a> *)</font></strong>;

<a name="line96"> 96: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorLinearSetFitIntercept.html">PetscRegressorLinearSetFitIntercept</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, <a href="../manualpages/Sys/PetscBool.html">PetscBool</a>)</font></strong>;
<a name="line97"> 97: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorLinearSetUseKSP.html">PetscRegressorLinearSetUseKSP</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, <a href="../manualpages/Sys/PetscBool.html">PetscBool</a>)</font></strong>;
<a name="line98"> 98: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorLinearGetKSP.html">PetscRegressorLinearGetKSP</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, <a href="../manualpages/KSP/KSP.html">KSP</a> *)</font></strong>;
<a name="line99"> 99: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorLinearGetCoefficients.html">PetscRegressorLinearGetCoefficients</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, <a href="../manualpages/Vec/Vec.html">Vec</a> *)</font></strong>;
<a name="line100">100: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorLinearGetIntercept.html">PetscRegressorLinearGetIntercept</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, <a href="../manualpages/Sys/PetscScalar.html">PetscScalar</a> *)</font></strong>;
<a name="line101">101: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorLinearSetType.html">PetscRegressorLinearSetType</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, <a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">PetscRegressorLinearType</a>)</font></strong>;
<a name="line102">102: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/PetscRegressor/PetscRegressorLinearGetType.html">PetscRegressorLinearGetType</a>(<a href="../manualpages/PetscRegressor/PetscRegressor.html">PetscRegressor</a>, <a href="../manualpages/PetscRegressor/PetscRegressorLinearType.html">PetscRegressorLinearType</a> *)</font></strong>;
</pre>
</body>

</html>