Skip to content

Commit

Permalink
Fix flake8 errors (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
kachayev authored Jan 26, 2024
1 parent d4eb894 commit 3e84668
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
5 changes: 4 additions & 1 deletion skada/_subspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@ def fit(self, X, y=None, sample_domain=None, **kwargs):
allow_multi_source=True,
allow_multi_target=True,
)
self.X_source_, self.X_target_ = source_target_split(X, sample_domain=sample_domain)
self.X_source_, self.X_target_ = source_target_split(
X,
sample_domain=sample_domain
)

Kss = pairwise_kernels(self.X_source_, metric=self.kernel)
Ktt = pairwise_kernels(self.X_target_, metric=self.kernel)
Expand Down
18 changes: 10 additions & 8 deletions skada/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ def _score(self, estimator, X, y, sample_domain=None, **params):

X, y, sample_domain = check_X_y_domain(X, y, sample_domain)
X_source, X_target, y_source, _ = source_target_split(
X, y, sample_domain=sample_domain
)
X,
y,
sample_domain=sample_domain
)
self._fit(X_source, X_target)
ws = self.weight_estimator_source_.score_samples(X_source)
wt = self.weight_estimator_target_.score_samples(X_source)
Expand Down Expand Up @@ -333,10 +335,10 @@ def __init__(
self._sign = 1 if greater_is_better else -1

def _no_reduc_log_loss(self, y, y_pred):
return np.array(
[
log_loss(y[i : i + 1], y_pred[i : i + 1], labels=np.unique(y))
for i in range(len(y))
return np.array(
[
log_loss(y[i : i + 1], y_pred[i : i + 1], labels=np.unique(y))
for i in range(len(y))
]
)

Expand All @@ -362,12 +364,12 @@ def _score(self, estimator, X, y, sample_domain=None, **kwargs):
features_train = estimator.get_features(X_train)
features_val = estimator.get_features(X_val)
features_target = estimator.get_features(X[~source_idx])

self._fit_adapt(features_train, features_target)
N, N_target = len(features_train), len(features_target)
predictions = self.domain_classifier_.predict_proba(features_val)
weights = N / N_target * predictions[:, :1] / predictions[:, 1:]

y_pred = estimator.predict_proba(X_val, sample_domain=sample_domain_val)
error = self._loss_func(y_val, y_pred)
assert weights.shape[0] == error.shape[0]
Expand Down

0 comments on commit 3e84668

Please sign in to comment.