Skip to content

Commit

Permalink
add sklearn__init, lruq and updates on lhc
Browse files Browse the repository at this point in the history
  • Loading branch information
jkitchin committed Jul 9, 2024
1 parent 41550a5 commit 1668225
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Empty file added pycse/sklearn/__init__.py
Empty file.
4 changes: 3 additions & 1 deletion pycse/sklearn/lhc.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ def anova(self):

table = np.vstack([ns.index.values, ns.values, ns > fc]).T

return pd.DataFrame(table, columns=[f"{self.y} effect", "F-score", "Significant"])
return pd.DataFrame(
table, columns=[f"{self.y} effect", f"F-score (fc={fc:1.1f})", "Significant"]
)

def predict(self, args):
"""Predict the response for ARGS. ARGS is a list of labels in order
Expand Down
22 changes: 22 additions & 0 deletions pycse/sklearn/lr_uq.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
A Linear regressor with uncertainty quantification.
"""
import numpy as np
from pycse import regress
from pycse import predict as _predict
from sklearn.base import BaseEstimator, RegressorMixin


class LinearRegressionUQ(BaseEstimator, RegressorMixin):
def fit(self, X, y):
self.xtrain = np.array(X)
self.ytrain = np.array(y)
self.coefs_, self.pars_cint, self.pars_se = regress(X, y, rcond=None)
return self

def predict(self, X, return_std=False):
y, _, se = _predict(self.xtrain, self.ytrain, self.coefs_, X)
if return_std:
return y, se
else:
return y

0 comments on commit 1668225

Please sign in to comment.