Skip to content

Commit

Permalink
do v0.12.3
Browse files Browse the repository at this point in the history
  • Loading branch information
thierrymoudiki committed Apr 16, 2024
1 parent 21b4771 commit fe2b99b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# version 0.12.2
# version 0.12.3

- add prediction intervals to `LSBoostRegressor` (split conformal prediction,
split conformal prediction with Kernel Density Estimation, and split
conformal prediction bootstrap)
see `examples/lsboost_regressor_pi.py` for examples
- do not rescale columns with zero variance in `LSBoostRegressor` and `LSBoostClassifier`
- faster ridge regression for `LSBoostRegressor`
- faster ridge regression for `LSBoostRegressor` and `LSBoostClassifier`

# version 0.9.0

Expand Down
4 changes: 3 additions & 1 deletion mlsauce/lasso/_lasso.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from sklearn.base import RegressorMixin
from numpy.linalg import inv
from . import _lassoc as mo
from ..utils import get_beta

if platform.system() in ("Linux", "Darwin"):
import jax.numpy as jnp
Expand Down Expand Up @@ -83,7 +84,8 @@ def fit(self, X, y, **kwargs):
Xy2 = 2 * Xy

if self.backend == "cpu":
beta0, _, _, _ = np.linalg.lstsq(X_, centered_y, rcond=None)
#beta0, _, _, _ = np.linalg.lstsq(X_, centered_y, rcond=None)
beta0 = get_beta(X_, centered_y)
if len(np.asarray(y).shape) == 1:
res = mo.get_beta_1D(
beta0=np.asarray(beta0),
Expand Down
7 changes: 5 additions & 2 deletions mlsauce/ridge/_ridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from sklearn.base import RegressorMixin
from numpy.linalg import inv
from . import _ridgec as mo
from ..utils import get_beta

if platform.system() in ("Linux", "Darwin"):
import jax.numpy as jnp
Expand Down Expand Up @@ -73,13 +74,15 @@ def fit(self, X, y, **kwargs):
eye_term = np.sqrt(self.reg_lambda) * np.eye(X.shape[1])
X_ = np.row_stack((X_, eye_term))
y_ = np.concatenate((centered_y, np.zeros(X.shape[1])))
self.beta, _, _, _ = np.linalg.lstsq(X_, y_, rcond=None)
#self.beta, _, _, _ = np.linalg.lstsq(X_, y_, rcond=None)
self.beta = get_beta(X_, y_)
else:
try:
eye_term = np.sqrt(self.reg_lambda) * np.eye(X.shape[1])
X_ = np.row_stack((X_, eye_term))
y_ = np.row_stack((centered_y, np.zeros((eye_term.shape[0], centered_y.shape[1]))))
self.beta, _, _, _ = np.linalg.lstsq(X_, y_, rcond=None)
#self.beta, _, _, _ = np.linalg.lstsq(X_, y_, rcond=None)
self.beta = get_beta(X_, y_)
except Exception:
x = inv(mo.crossprod(X_) + self.reg_lambda * np.eye(X_.shape[1]))
hat_matrix = mo.tcrossprod(x, X_)
Expand Down
2 changes: 2 additions & 0 deletions mlsauce/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .sampling.rowsubsampling import subsample
from .misc.misc import merge_two_dicts, flatten, is_float, is_factor
from .progress_bar import Progbar
from .get_beta import get_beta

__all__ = [
"subsample",
Expand All @@ -9,4 +10,5 @@
"is_float",
"is_factor",
"Progbar",
"get_beta"
]
4 changes: 4 additions & 0 deletions mlsauce/utils/get_beta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import numpy as np

def get_beta(X, y):
return np.linalg.solve(X.T @ X, X.T @ y)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
MAINTAINER_EMAIL = '[email protected]'
LICENSE = 'BSD3 Clause Clear'

__version__ = '0.12.2'
__version__ = '0.12.3'

VERSION = __version__

Expand Down

0 comments on commit fe2b99b

Please sign in to comment.