Coverage for src/pycse/sklearn/lr_uq.py: 0.00%
15 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-23 16:23 -0400
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-23 16:23 -0400
1"""
2A Linear regressor with uncertainty quantification.
3"""
5import numpy as np
6from pycse import regress
7from pycse import predict as _predict
8from sklearn.base import BaseEstimator, RegressorMixin
11class LinearRegressionUQ(BaseEstimator, RegressorMixin):
12 def fit(self, X, y):
13 self.xtrain = np.array(X)
14 self.ytrain = np.array(y)
15 self.coefs_, self.pars_cint, self.pars_se = regress(X, y, rcond=None)
16 return self
18 def predict(self, X, return_std=False):
19 y, _, se = _predict(self.xtrain, self.ytrain, self.coefs_, X)
20 if return_std:
21 return y, se
22 else:
23 return y