Skip to content

Commit

Permalink
Remvoed an error
Browse files Browse the repository at this point in the history
  • Loading branch information
prithagupta committed Oct 23, 2024
1 parent bd3c4e8 commit 62a8723
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 51 deletions.
13 changes: 1 addition & 12 deletions autoqild/bayes_search/bayes_search_cv.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,7 @@ class BayesSearchCV(BayesSearchCVSK):
configurations based on the Bayesian optimization strategy.
"""

def __init__(
self,
estimator,
search_spaces,
optimizer_kwargs=None,
n_iter=50,
scoring=None,
fit_params=None,
n_jobs=1,
n_points=1,
iid=True,
refit=True,
def __init__(self, estimator, search_spaces, optimizer_kwargs=None, n_iter=50, scoring=None, fit_params=None, n_jobs=1, n_points=1, iid=True, refit=True,
cv=None,
verbose=0,
pre_dispatch="2*n_jobs",
Expand Down
8 changes: 5 additions & 3 deletions autoqild/dataset_readers/open_ml_padding_dr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from .open_ml_timming_dr import OpenMLTimingDatasetReader
from .utils import *

import pandas as pd

class OpenMLPaddingDatasetReader(OpenMLTimingDatasetReader):
"""Reader for OpenML datasets related to leakages with respect to the error
Expand Down Expand Up @@ -118,6 +118,8 @@ def __read_dataset__(self):
vulnerable_classes_str = description.split("\n")[-1].split("vulnerable_classes ")[-1]
vulnerable_classes_str = vulnerable_classes_str.strip("[]")
self.vulnerable_classes = [s.strip() for s in vulnerable_classes_str.split(",")]
if self.vulnerable_classes == ['']:
self.vulnerable_classes = []
self.n_features = len(self.dataset.features) - 1
self.server = self.dataset.name.split("padding-attack-dataset-")[-1]

Expand All @@ -143,7 +145,7 @@ def get_data(self, class_label=1):
y : array-like of shape (n_samples,)
Target vector.
"""
super().get_data(class_label=class_label)
return super().get_data(class_label=class_label)

def get_sampled_imbalanced_data(self, X, y):
"""Creates an imbalanced dataset by sampling from the data.
Expand All @@ -164,4 +166,4 @@ def get_sampled_imbalanced_data(self, X, y):
y : array-like of shape (n_samples,)
Target vector after applying sampling to create imbalance.
"""
super().get_sampled_imbalanced_data(X=X, y=y)
return super().get_sampled_imbalanced_data(X=X, y=y)
13 changes: 2 additions & 11 deletions autoqild/dataset_readers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@

import numpy as np

__all__ = [
"GEN_TYPES",
"FACTOR",
"LABEL_COL",
"generate_samples_per_class",
"clean_class_label",
"pdf",
]
__all__ = ["GEN_TYPES", "FACTOR", "LABEL_COL", "generate_samples_per_class", "clean_class_label", "pdf"]

GEN_TYPES = ["single", "multiple"]
"""
Expand All @@ -29,9 +22,7 @@
"""Default label column name used in datasets."""


def generate_samples_per_class(
n_classes, samples=1000, imbalance=0.05, gen_type="single", logger=None, verbose=1
):
def generate_samples_per_class(n_classes, samples=1000, imbalance=0.05, gen_type="single", logger=None, verbose=1):
"""Generate the number of samples per class with a specified imbalance.
This function calculates the number of samples for each class based on the provided imbalance ratio and the generation type.
Expand Down
29 changes: 4 additions & 25 deletions autoqild/utilities/statistical_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,7 @@ def wilcoxon_signed_rank_test(accuracies, accuracies2, alternative="two-sided",
return p_value


def paired_ttest(
x1,
x2,
n_training_folds,
n_test_folds,
correction=True,
alternative="two-sided",
verbose=False,
):
def paired_ttest(x1, x2, n_training_folds, n_test_folds, correction=True, alternative="two-sided", verbose=False,):
"""Performs a paired t-test on two sets of values with and without
correction.
Expand Down Expand Up @@ -110,22 +102,9 @@ def paired_ttest(
elif alternative == "two-sided":
p_value = 2 * t.sf(np.abs(t_static), df)
if verbose:
logger.info(
"Final Variance {} Sigma {} t_static {} p {}".format(
sigma2, np.sqrt(sigma2), t_static, p_value
)
)
logger.info(
"np.isnan(p) {}, np.isinf {}, d_bar == 0 {}, sigma2_mod == 0 {}, np.isinf(t_static) {}, "
"np.isnan(t_static) {}".format(
np.isnan(p_value),
np.isinf(p_value),
d_bar == 0,
sigma2 == 0,
np.isinf(t_static),
np.isnan(t_static),
)
)
logger.info(f"Final Variance {sigma2} Sigma {np.sqrt(sigma2)} t_static {t_static} p {p_value}")
logger.info(f"np.isnan(p) {np.isnan(p_value)}, np.isinf {np.isinf(p_value)}, d_bar == 0 {d_bar == 0}, sigma2_mod == 0 {sigma2 == 0}, np.isinf(t_static) {np.isinf(t_static)}, "
f"np.isnan(t_static) {np.isnan(t_static)}")
if (
np.isnan(p_value)
or np.isinf(p_value)
Expand Down

0 comments on commit 62a8723

Please sign in to comment.