Skip to content

Commit

Permalink
Replacing csd in sample selection with california because the larger …
Browse files Browse the repository at this point in the history
…dataset means a few redundant samples, which is not good for stable testing
  • Loading branch information
rosecers committed May 16, 2022
1 parent f6278b6 commit 8441ac0
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, "skcosmo.tex", u"scikit-COSMO Documentation", author, "manual"),
(master_doc, "skcosmo.tex", "scikit-COSMO Documentation", author, "manual"),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down
2 changes: 1 addition & 1 deletion examples/PlotLFRE.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"ax34.set_title(r\"$X^-$ LFRE(3-body, 4-body)\")\n",
"ax43.set_title(r\"$X^-$ LFRE(4-body, 3-body)\")\n",
"\n",
"cbar = fig.colorbar(pcm, ax=(ax34, ax43), label=\"LFRE\", location=\"bottom\")\n",
"cbar = fig.colorbar(pcm, ax=[ax34, ax43], label=\"LFRE\", location=\"bottom\")\n",
"\n",
"plt.show()"
]
Expand Down
2 changes: 1 addition & 1 deletion skcosmo/_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ def _init_greedy_search(self, X, y, n_to_select):

super()._init_greedy_search(X, y, n_to_select)

self.norms_ = (X ** 2).sum(axis=abs(self._axis - 1))
self.norms_ = (X**2).sum(axis=abs(self._axis - 1))
self.haussdorf_ = np.full(X.shape[self._axis], np.inf)
self.haussdorf_at_select_ = np.full(X.shape[self._axis], np.inf)

Expand Down
2 changes: 1 addition & 1 deletion skcosmo/decomposition/_kernel_pcovr.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def _decompose_full(self, mat):
U, Vt = svd_flip(U, Vt)

# Get variance explained by singular values
explained_variance_ = (S ** 2) / (self.n_samples_ - 1)
explained_variance_ = (S**2) / (self.n_samples_ - 1)
total_var = explained_variance_.sum()
explained_variance_ratio_ = explained_variance_ / total_var

Expand Down
4 changes: 2 additions & 2 deletions skcosmo/metrics/_reconstruction_measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ def pointwise_local_reconstruction_error(
Y_test = scaler.transform(Y_test)

squared_dist = (
np.sum(X_train ** 2, axis=1)
+ np.sum(X_test ** 2, axis=1)[:, np.newaxis]
np.sum(X_train**2, axis=1)
+ np.sum(X_test**2, axis=1)[:, np.newaxis]
- 2 * X_test @ X_train.T
)

Expand Down
2 changes: 1 addition & 1 deletion skcosmo/sample_selection/_voronoi_fps.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def _init_greedy_search(self, X, y, n_to_select):

super()._init_greedy_search(X, y, n_to_select)

self.norms_ = (X ** 2).sum(axis=abs(self._axis - 1))
self.norms_ = (X**2).sum(axis=abs(self._axis - 1))

if self.initialize == "random":
random_state = check_random_state(self.random_state)
Expand Down
4 changes: 2 additions & 2 deletions skcosmo/utils/_pcovr_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ def pcovr_covariance(
random_state=random_state,
)

UC = UC.T[:, (vC ** 2) > rcond]
vC = vC[(vC ** 2) > rcond]
UC = UC.T[:, (vC**2) > rcond]
vC = vC[(vC**2) > rcond]

C_isqrt = UC @ np.diagflat(1.0 / vC) @ UC.T

Expand Down
7 changes: 4 additions & 3 deletions tests/test_sample_simple_cur.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import numpy as np
from sklearn import exceptions

from skcosmo.datasets import load_csd_1000r as load
from sklearn.datasets import fetch_california_housing as load
from skcosmo.sample_selection import CUR


class TestCUR(unittest.TestCase):
def setUp(self):
self.X, self.y = load(return_X_y=True)
self.n_select = 20
self.X, _ = load(return_X_y=True)
self.X = self.X[:1000]
self.n_select = min(20, min(self.X.shape) // 2)

def test_bad_transform(self):
selector = CUR(n_to_select=2)
Expand Down

0 comments on commit 8441ac0

Please sign in to comment.