Normalization regressor
Linear Atom Energies regression utilities.
LinearSolver
¶
Bases: Solver
Linear regression solver.
Note
No Uncertainty associated as it is quite small.
Source code in openqdc/utils/regressor.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
Regressor
¶
Regressor class for preparing and solving regression problem for isolated atom energies. A isolated atom energy regression problem is defined as:
X = [n_samples, n_species] (number of atoms of each species per sample)
Y = [n_samples, ] (energies)
The regression problem is solved by solving the linear system X E0 = Y.
Example
For a sytem of 2 samples (H20, CH4)
n_species = 3, n_samples = 2
H20 = 2H , 1O -> X = [2, 1, 0]
CH4 = 4C, 1H -> X = [1, 0, 4]
X = [[2, 1, 0],
[ 1, 0, 4]]
Y = [[10, 20]]
X E0 = Y
Linear system to solve
[[2 eH, 1 eO, 0 eC],
[ 1 eH, 0 eO, 4 eC]] = [[10, 20]]
Source code in openqdc/utils/regressor.py
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
|
__init__(energies, atomic_numbers, position_idx_range, solver_type='linear', stride=1, subsample=None, remove_nan=True, *args, **kwargs)
¶
Regressor class for preparing and solving regression problem for isolated atom energies.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
energies |
ndarray
|
numpy array of energies in the shape (n_samples, n_energy_methods) |
required |
atomic_numbers |
ndarray
|
numpy array of atomic numbers in the shape (n_atoms,) |
required |
position_idx_range |
ndarray
|
array of shape (n_samples, 2) containing the start and end indices of the atoms in the dataset |
required |
solver_type |
str
|
Type of solver to use. ["linear", "ridge"] |
'linear'
|
stride |
int
|
Stride to use for the regression. |
1
|
subsample |
Optional[Union[float, int]]
|
Sumsample the dataset. If a float, it is interpreted as a fraction of the dataset to use. If >1 it is interpreted as the number of samples to use. |
None
|
remove_nan |
bool
|
Sanitize the dataset by removing energies samples with NaN values. |
True
|
*args |
any
|
Additional arguments to be passed to the regressor. |
()
|
**kwargs |
any
|
Additional keyword arguments to be passed to the regressor. |
{}
|
Source code in openqdc/utils/regressor.py
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 |
|
from_openqdc_dataset(dataset, *args, **kwargs)
classmethod
¶
Initialize the regressor object from an openqdc dataset. This is the default method. args and and *kwargs are passed to the init method and depends on the specific regressor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset |
any
|
openqdc dataset object. |
required |
*args |
any
|
Additional arguments to be passed to the regressor. |
()
|
**kwargs |
any
|
Additional keyword arguments to be passed to the regressor. |
{}
|
Returns:
Type | Description |
---|---|
Regressor
|
Instance of the regressor class. |
Source code in openqdc/utils/regressor.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
solve()
¶
Solve the regression problem and return the predicted isolated energies and the estimated uncertainty.
Source code in openqdc/utils/regressor.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|
RidgeSolver
¶
Bases: Solver
Ridge regression solver.
Source code in openqdc/utils/regressor.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
Solver
¶
Bases: ABC
Abstract class for regression solvers.
Source code in openqdc/utils/regressor.py
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 |
|
solve(X, Y)
abstractmethod
staticmethod
¶
Main method to solve the regression problem. Must be implemented in all the subclasses.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
ndarray
|
Input features of shape (n_samples, n_species) |
required |
Y |
ndarray
|
Target values of shape (n_samples,) (energy values for the regression) |
required |
Returns:
Type | Description |
---|---|
Tuple[ndarray, Optional[ndarray]]
|
Tuple of predicted values and the estimated uncertainty. |
Source code in openqdc/utils/regressor.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
atom_standardization(X, y)
¶
Standardize the energies and the atom counts. This will make the calculated uncertainty more meaningful.
Source code in openqdc/utils/regressor.py
203 204 205 206 207 208 209 210 211 212 213 |
|
non_nan_idxs(array)
¶
Return non nan indices of an array.
Source code in openqdc/utils/regressor.py
11 12 13 14 15 |
|