-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathlibsvm.py
More file actions
31 lines (21 loc) · 798 Bytes
/
libsvm.py
File metadata and controls
31 lines (21 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from benchopt import BaseDataset, safe_import_context
with safe_import_context() as import_ctx:
from libsvmdata import fetch_libsvm
preprocess_data = import_ctx.import_from("utils", "preprocess_data")
class Dataset(BaseDataset):
name = "libsvm"
parameters = {
"dataset": ["finance", "finance-tf-idf", "YearPredictionMSD"],
"standardize" : [True, False]
}
install_cmd = "conda"
requirements = ["pip:libsvmdata"]
def __init__(self, dataset="bodyfat", standardize=True):
self.dataset = dataset
self.X, self.y = None, None
self.standardize = standardize
def get_data(self):
X, y = fetch_libsvm(self.dataset)
if self.standardize:
X, y = preprocess_data(X, y)
return dict(X=X, y=y)