Skip to content

Commit

Permalink
new runs added Merge remote-tracking branch 'origin/runs'
Browse files Browse the repository at this point in the history
  • Loading branch information
mijanr committed Mar 18, 2024
2 parents d7e0226 + 136bc72 commit 78115c0
Show file tree
Hide file tree
Showing 2,250 changed files with 34,514 additions and 7 deletions.
101 changes: 101 additions & 0 deletions codes/models/InceptionTime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from tsai.all import *
import fastai
from tsai.models.InceptionTime import InceptionTime
import numpy as np

class InceptionTime_classifier:
"""
InceptionTime classifier for time series classification
Parameters
----------
c_in: int
Number of input channels
c_out: int
Number of classes
seq_len: int
Length of the input sequence
nf: int
Number of filters
nb_filters: int
Number of filters in the inception module
ks: int
Kernel size
bottleneck: bool
Whether to use bottleneck
Attributes
----------
model: nn.Module
InceptionTime model
"""

def __init__(
self,
c_in,
c_out,
seq_len,
nf=32,
nb_filters=32,
ks=40,
bottleneck=True,
**kwargs
):
self.model = InceptionTime(
c_in=c_in,
c_out=c_out,
seq_len=seq_len,
nf=nf,
nb_filters=nb_filters,
ks=ks,
bottleneck=bottleneck,
)

def fit(
self,
X: np.ndarray,
y: np.ndarray,
splits: list,
test_data: dict,
epochs: int,
lr: float
):
"""
Fit the model on the training data
Parameters
----------
X: np.ndarray
Input data
y: np.ndarray
Target data
splits: list
List of indices for training and validation splits
test_data: dict
Dictionary of test data
{'X': X_test, 'y': y_test}
epochs: int
Number of epochs to train
lr: float
Learning rate
"""
tfms = [None, [Categorize()]]
dsets = TSDatasets(X, y, tfms=tfms, splits=splits, inplace=True)
dls = TSDataLoaders.from_dsets(dsets.train, dsets.valid, bs=[64, 128], batch_tfms=[TSStandardize()], num_workers=0)
learn = Learner(dls, self.model, metrics=fastai.metrics.accuracy)
learn.fit_one_cycle(epochs, lr)

#now add the test data to the dls
test_ds = dls.valid.dataset.add_test(**test_data)
test_dl = dls.valid.new(test_ds)

#get the predictions
_, test_targets, test_preds = learn.get_preds(dl=test_dl, with_decoded=True)
accuracy = skm.accuracy_score(test_targets, test_preds)
cl_report = skm.classification_report(test_targets, test_preds, output_dict=True)
return {"accuracy": accuracy, "cl_report": cl_report, "target": test_targets, "pred": test_preds}


if __name__ == "__main__":
# instantiate the model
model = InceptionTime_classifier(c_in=1, c_out=2, seq_len=100)
Binary file not shown.
Binary file not shown.
Binary file modified codes/models/__pycache__/LSTM_FCN.cpython-310.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion configs/main_config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defaults:
- _self_
- datasets: dataset_params
- models: LSTM_FCN
- models: InceptionTime
- [email protected]: ${models}
- override hydra/sweeper: optuna
dataset_name:
Expand Down
6 changes: 6 additions & 0 deletions configs/models/InceptionTime.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
model:
_target_: codes.models.InceptionTime.InceptionTime_classifier
nf: 32
nb_filters: 32
ks: 40
bottleneck: True
4 changes: 4 additions & 0 deletions configs/search_spaces/InceptionTime.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
models.model.nf: choice(8, 16, 32, 64, 128)
models.model.nb_filters: choice(8, 16, 32, 64, 128)
models.model.ks: choice(10, 20, 40, 80, 160)
models.model.bottleneck: bool (True, False)
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"0": {
"precision": 0.8205128205128205,
"recall": 0.8888888888888888,
"f1-score": 0.8533333333333333,
"support": 36
},
"1": {
"precision": 0.9344262295081968,
"recall": 0.890625,
"f1-score": 0.9120000000000001,
"support": 64
},
"accuracy": 0.89,
"macro avg": {
"precision": 0.8774695250105087,
"recall": 0.8897569444444444,
"f1-score": 0.8826666666666667,
"support": 100
},
"weighted avg": {
"precision": 0.8934174022698613,
"recall": 0.89,
"f1-score": 0.8908800000000001,
"support": 100
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"nf": 128,
"nb_filters": 16,
"ks": 80,
"bottleneck": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
artifact_uri: file:///home/pops/myProjects/ts_classification_mlflow_hydra_optuna/mlruns/952712754232464717/00714c6614ac4a79b5bd18121c2c5e2a/artifacts
end_time: 1710766329484
entry_point_name: ''
experiment_id: '952712754232464717'
lifecycle_stage: active
run_id: 00714c6614ac4a79b5bd18121c2c5e2a
run_name: ECG200
run_uuid: 00714c6614ac4a79b5bd18121c2c5e2a
source_name: ''
source_type: 4
source_version: ''
start_time: 1710766329473
status: 3
tags: []
user_id: pops
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766329478 0.89 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766329479 0.8908800000000001 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766329480 0.8826666666666667 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766329479 0.8774695250105087 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766329480 0.8897569444444444 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766329480 100.0 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
500
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.001
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
InceptionTime
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ECG200
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fe8042a2f33aa638b2c8945a75a751b3357866df
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LOCAL
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pops
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"0": {
"precision": 0.7804878048780488,
"recall": 0.8888888888888888,
"f1-score": 0.8311688311688312,
"support": 36
},
"1": {
"precision": 0.9322033898305084,
"recall": 0.859375,
"f1-score": 0.8943089430894309,
"support": 64
},
"accuracy": 0.87,
"macro avg": {
"precision": 0.8563455973542786,
"recall": 0.8741319444444444,
"f1-score": 0.862738887129131,
"support": 100
},
"weighted avg": {
"precision": 0.8775857792476229,
"recall": 0.87,
"f1-score": 0.871578502798015,
"support": 100
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"nf": 128,
"nb_filters": 16,
"ks": 80,
"bottleneck": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
artifact_uri: file:///home/pops/myProjects/ts_classification_mlflow_hydra_optuna/mlruns/952712754232464717/038fa8dac5a84d95842602f3f02dd92e/artifacts
end_time: 1710766637731
entry_point_name: ''
experiment_id: '952712754232464717'
lifecycle_stage: active
run_id: 038fa8dac5a84d95842602f3f02dd92e
run_name: ECG200
run_uuid: 038fa8dac5a84d95842602f3f02dd92e
source_name: ''
source_type: 4
source_version: ''
start_time: 1710766637721
status: 3
tags: []
user_id: pops
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766637725 0.87 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766637726 0.871578502798015 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766637728 0.862738887129131 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766637726 0.8563455973542786 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766637727 0.8741319444444444 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766637727 100.0 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
500
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.001
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
InceptionTime
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ECG200
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fe8042a2f33aa638b2c8945a75a751b3357866df
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LOCAL
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pops
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"0": {
"precision": 0.8378378378378378,
"recall": 0.8611111111111112,
"f1-score": 0.8493150684931507,
"support": 36
},
"1": {
"precision": 0.9206349206349206,
"recall": 0.90625,
"f1-score": 0.9133858267716536,
"support": 64
},
"accuracy": 0.89,
"macro avg": {
"precision": 0.8792363792363792,
"recall": 0.8836805555555556,
"f1-score": 0.8813504476324021,
"support": 100
},
"weighted avg": {
"precision": 0.8908279708279707,
"recall": 0.89,
"f1-score": 0.8903203537913926,
"support": 100
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"nf": 128,
"nb_filters": 128,
"ks": 40,
"bottleneck": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
artifact_uri: file:///home/pops/myProjects/ts_classification_mlflow_hydra_optuna/mlruns/952712754232464717/05edaa4acc1548f087835c211c9f5f49/artifacts
end_time: 1710766537806
entry_point_name: ''
experiment_id: '952712754232464717'
lifecycle_stage: active
run_id: 05edaa4acc1548f087835c211c9f5f49
run_name: ECG200
run_uuid: 05edaa4acc1548f087835c211c9f5f49
source_name: ''
source_type: 4
source_version: ''
start_time: 1710766537795
status: 3
tags: []
user_id: pops
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766537800 0.89 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766537800 0.8903203537913926 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766537802 0.8813504476324021 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766537801 0.8792363792363792 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766537801 0.8836805555555556 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1710766537802 100.0 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
500
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.001
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
InceptionTime
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ECG200
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fe8042a2f33aa638b2c8945a75a751b3357866df
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LOCAL
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pops
Loading

0 comments on commit 78115c0

Please sign in to comment.