Skip to content

Commit 33e5fe4

Browse files
committed
add benchmark
1 parent 733677c commit 33e5fe4

File tree

40 files changed

+41817
-29
lines changed

40 files changed

+41817
-29
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from benchopt import BaseDataset, safe_import_context
2+
from sklearn.preprocessing import StandardScaler
3+
import numpy as np
4+
with safe_import_context() as import_ctx:
5+
from benchopt.datasets import make_correlated_data
6+
7+
8+
class Dataset(BaseDataset):
9+
10+
name = "Classification_sim"
11+
12+
parameters = {
13+
'n_samples, n_features': [
14+
(100, 10),
15+
(300, 10),
16+
(500, 10),
17+
(700, 10),
18+
(1000, 10)]
19+
}
20+
21+
def __init__(self, n_samples=10, n_features=50, random_state=42):
22+
self.n_samples = n_samples
23+
self.n_features = n_features
24+
self.random_state = random_state
25+
26+
def get_data(self):
27+
X, y, _ = make_correlated_data(
28+
n_samples=self.n_samples, n_features=self.n_features,
29+
random_state=self.random_state
30+
)
31+
y = 2*(y > 0) - 1
32+
33+
scaler = StandardScaler()
34+
X = scaler.fit_transform(X)
35+
36+
n, d = X.shape
37+
x_sensitive = X[:,np.random.randint(d)]
38+
x_sensitive = x_sensitive - np.mean(x_sensitive)
39+
data = dict(X=X, y=y, Z=x_sensitive)
40+
41+
return self.n_features, data
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from benchopt import BaseDataset, safe_import_context
2+
from sklearn.preprocessing import StandardScaler
3+
import numpy as np
4+
with safe_import_context() as import_ctx:
5+
from benchopt.datasets import make_correlated_data
6+
7+
8+
class Dataset(BaseDataset):
9+
10+
name = "reg_sim"
11+
12+
parameters = {
13+
'n_samples, n_features': [
14+
(100, 10),
15+
(300, 10),
16+
(500, 10),
17+
(700, 10),
18+
(1000, 10)]
19+
}
20+
21+
def __init__(self, n_samples=10, n_features=50, random_state=42):
22+
self.n_samples = n_samples
23+
self.n_features = n_features
24+
self.random_state = random_state
25+
26+
def get_data(self):
27+
X, y, _ = make_correlated_data(
28+
n_samples=self.n_samples, n_features=self.n_features,
29+
random_state=self.random_state
30+
)
31+
32+
scaler = StandardScaler()
33+
X = scaler.fit_transform(X)
34+
35+
n, d = X.shape
36+
data = dict(X=X, y=y, q=0.1)
37+
38+
return self.n_features, data

0 commit comments

Comments
 (0)