Skip to content

Commit

Permalink
Merge pull request #25 from Techtonique/faster-ridge
Browse files Browse the repository at this point in the history
Faster ridge
  • Loading branch information
thierrymoudiki authored Apr 15, 2024
2 parents cfdc474 + 0835a92 commit 2843a56
Show file tree
Hide file tree
Showing 25 changed files with 2,272 additions and 2,556 deletions.
6 changes: 4 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# version 0.12.0
# version 0.12.1

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

# version 0.9.0

Expand Down
2 changes: 2 additions & 0 deletions examples/adaopt_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
#chdir(wd)

import mlsauce as ms
import os

print(f"\n ----- Running: {os.path.basename(__file__)}... ----- \n")



Expand Down
4 changes: 4 additions & 0 deletions examples/download_dataset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import mlsauce as ms
import os

print(f"\n ----- Running: {os.path.basename(__file__)}... ----- \n")


# `ms.download` parameters
# pkgname="MASS"
Expand Down
4 changes: 4 additions & 0 deletions examples/lasso_regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
from time import time
from os import chdir
from sklearn import metrics
import os

print(f"\n ----- Running: {os.path.basename(__file__)}... ----- \n")


# data 2
diabetes = load_diabetes()
Expand Down
4 changes: 4 additions & 0 deletions examples/lsboost_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
from time import time
from os import chdir
from sklearn import metrics
import os

print(f"\n ----- Running: {os.path.basename(__file__)}... ----- \n")



#wd="/workspace/mlsauce/mlsauce/examples"
Expand Down
4 changes: 4 additions & 0 deletions examples/lsboost_regressor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import subprocess
import sys
import os

print(f"\n ----- Running: {os.path.basename(__file__)}... ----- \n")


subprocess.check_call([sys.executable, "-m", "pip", "install", "matplotlib"])

Expand Down
26 changes: 15 additions & 11 deletions examples/lsboost_regressor_pi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import subprocess
import sys
import os

print(f"\n ----- Running: {os.path.basename(__file__)}... ----- \n")


subprocess.check_call([sys.executable, "-m", "pip", "install", "matplotlib"])

Expand Down Expand Up @@ -31,7 +35,7 @@
print(obj.get_params())
start = time()
obj.fit(X_train, y_train)
print(time()-start)
print(f"Elapsed: {time()-start}")
start = time()
preds = obj.predict(X_test, return_pi=True, method="splitconformal")
print(time()-start)
Expand All @@ -44,7 +48,7 @@
print(obj.get_params())
start = time()
obj.fit(X_train, y_train)
print(time()-start)
print(f"Elapsed: {time()-start}")
start = time()
preds = obj.predict(X_test, return_pi=True,
method="splitconformal")
Expand All @@ -58,7 +62,7 @@
print(obj.get_params())
start = time()
obj.fit(X_train, y_train)
print(time()-start)
print(f"Elapsed: {time()-start}")
start = time()
preds = obj.predict(X_test, return_pi=True,
method="splitconformal")
Expand All @@ -78,7 +82,7 @@
print(obj.get_params())
start = time()
obj.fit(X_train, y_train)
print(time()-start)
print(f"Elapsed: {time()-start}")
start = time()
preds = obj.predict(X_test, return_pi=True, method="splitconformal")
print(time()-start)
Expand All @@ -91,7 +95,7 @@
print(obj.get_params())
start = time()
obj.fit(X_train, y_train)
print(time()-start)
print(f"Elapsed: {time()-start}")
start = time()
preds = obj.predict(X_test, return_pi=True,
method="splitconformal")
Expand All @@ -105,7 +109,7 @@
print(obj.get_params())
start = time()
obj.fit(X_train, y_train)
print(time()-start)
print(f"Elapsed: {time()-start}")
start = time()
preds = obj.predict(X_test, return_pi=True,
method="splitconformal")
Expand Down Expand Up @@ -133,7 +137,7 @@
print(obj.get_params())
start = time()
obj.fit(X_train, y_train)
print(time()-start)
print(f"Elapsed: {time()-start}")
start = time()
preds = obj.predict(X_test, return_pi=True, method="splitconformal")
print(time()-start)
Expand All @@ -150,7 +154,7 @@
start = time()
preds = obj.predict(X_test, return_pi=True,
method="splitconformal")
print(time()-start)
print(f"Elapsed: {time()-start}")
print(f"splitconformal bootstrap coverage 3: {np.mean((preds.upper >= y_test)*(preds.lower <= y_test))}")


Expand All @@ -160,7 +164,7 @@
print(obj.get_params())
start = time()
obj.fit(X_train, y_train)
print(time()-start)
print(f"Elapsed: {time()-start}")
start = time()
preds = obj.predict(X_test, return_pi=True,
method="splitconformal")
Expand All @@ -181,7 +185,7 @@
print(obj.get_params())
start = time()
obj.fit(X_train, y_train)
print(time()-start)
print(f"Elapsed: {time()-start}")
start = time()
preds = obj.predict(X_test, return_pi=True, method="splitconformal")
print(time()-start)
Expand All @@ -208,7 +212,7 @@
print(obj.get_params())
start = time()
obj.fit(X_train, y_train)
print(time()-start)
print(f"Elapsed: {time()-start}")
start = time()
preds = obj.predict(X_test, return_pi=True,
method="splitconformal")
Expand Down
3 changes: 3 additions & 0 deletions examples/plot_ridge_lasso_coeffs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import subprocess
import sys
import os

print(f"\n ----- Running: {os.path.basename(__file__)}... ----- \n")

subprocess.check_call([sys.executable, "-m", "pip", "install", "matplotlib"])

Expand Down
4 changes: 4 additions & 0 deletions examples/ridge_regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
from time import time
from os import chdir
from sklearn import metrics
import os

print(f"\n ----- Running: {os.path.basename(__file__)}... ----- \n")



#wd="/workspace/mlsauce/mlsauce/examples"
Expand Down
4 changes: 4 additions & 0 deletions examples/stump_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
from time import time
from os import chdir
from sklearn import metrics
import os

print(f"\n ----- Running: {os.path.basename(__file__)}... ----- \n")



#wd="/workspace/mlsauce/mlsauce/examples"
Expand Down
2 changes: 1 addition & 1 deletion mlsauce.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: mlsauce
Version: 0.11.0
Version: 0.12.1
Summary: Miscellaneous Statistical/Machine Learning tools
Maintainer: T. Moudiki
Maintainer-email: [email protected]
Expand Down
2 changes: 1 addition & 1 deletion mlsauce/adaopt/_adaopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def fit(self, X, y, **kwargs):
self.alphas = res["alphas"]
self.n_iterations = res["n_iterations"]
self.scaled_X_train = np.array(res["scaled_X_train"], dtype=np.float64)

self.n_classes_ = len(np.unique(y)) # for compatibility with sklearn
return self

def predict(self, X, **kwargs):
Expand Down
Loading

0 comments on commit 2843a56

Please sign in to comment.