Skip to content

Commit ba35306

Browse files
committed
Add TSLime example notebook
1 parent 73b3368 commit ba35306

File tree

5 files changed

+612
-2
lines changed

5 files changed

+612
-2
lines changed

examples/TSLime.ipynb

Lines changed: 572 additions & 0 deletions
Large diffs are not rendered by default.

examples/data/FordA.zip

34.7 MB
Binary file not shown.

examples/utils/data.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import pandas as pd
2+
import os
3+
import zipfile
4+
def load_ford(category: str = "A", input_length: int = 500):
5+
"""
6+
Prepares train and test dataframes.
7+
8+
Returns:
9+
10+
x_train (np.ndarray): Train data in numpy format.
11+
x_test (np.ndarray): Test data in numpy format.
12+
y_train (np.ndarray): Train labels in numpy format.
13+
x_test (np.ndarray): Test labels in numpy format.
14+
"""
15+
_dir = os.path.dirname(os.path.abspath(__file__))
16+
data_file = os.path.join(_dir, f'../data/Ford{category}.zip')
17+
18+
with zipfile.ZipFile(data_file, 'r') as z:
19+
with z.open(f'Ford{category}_TRAIN.txt') as f:
20+
train = pd.read_csv(f, delim_whitespace=True, header=None)
21+
with z.open(f'Ford{category}_TEST.txt') as f:
22+
test = pd.read_csv(f, delim_whitespace=True, header=None)
23+
24+
y_train = train.iloc[:, 0]
25+
x_train = train.iloc[:, 1:]
26+
x_test = test.iloc[:, 1:]
27+
y_test = test.iloc[:, 0]
28+
29+
x_train = x_train.values.reshape(-1, input_length, 1)
30+
x_test = x_test.values.reshape(-1, input_length, 1)
31+
32+
y_train[y_train == -1] = 0
33+
y_test[y_test == -1] = 0
34+
35+
return x_train, x_test, y_train, y_test

requirements-examples.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
joblib~=1.1.1
1+
joblib~=1.2.0
22
pandas~=1.5.3
33
scikit-learn~=1.2.1
44
xgboost==1.4.2
55
matplotlib~=3.6.3
6+
tensorflow
7+
keras
8+
huggingface-hub

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
trustyai==0.2.10
1+
trustyai==0.2.12
22
jupyterlab~=3.5.3

0 commit comments

Comments
 (0)