Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tsc-pdm-event-log
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
lifo
Antoine Guillaume
tsc-pdm-event-log
Commits
1cf8d981
Commit
1cf8d981
authored
Feb 01, 2021
by
Antoine Guillaume
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pushing code version from paper
parent
93289677
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
16 deletions
+13
-16
CV_script.py
CV_script.py
+8
-12
classifications.cpython-38.pyc
utils/__pycache__/classifications.cpython-38.pyc
+0
-0
representations.cpython-38.pyc
utils/__pycache__/representations.cpython-38.pyc
+0
-0
classifications.py
utils/classifications.py
+2
-2
kernel_collection.npy
utils/kernel_collection.npy
+0
-0
representations.py
utils/representations.py
+3
-2
No files found.
CV_script.py
View file @
1cf8d981
...
...
@@ -142,14 +142,11 @@ life_cycles = np.asarray([process_cycle(file_name, dataset_path,
def
last_X_days
(
data
,
y
,
X
,
min_data
=
0.33
):
if
(
data
.
iloc
[
-
1
][
'date'
]
-
data
.
iloc
[
0
][
'date'
])
>=
timedelta
(
days
=
X
+
1
):
lim_date
=
pd
.
Timestamp
(
data
.
iloc
[
-
1
][
'date'
]
.
date
())
#Remove not complete day
data
=
data
[
data
[
'date'
]
<
lim_date
]
#Remove
date
=
pd
.
Timestamp
((
lim_date
-
timedelta
(
days
=
X
)))
data
=
data
.
drop
(
data
[
data
[
'date'
]
<
date
]
.
index
,
axis
=
0
)
#Remove last not complete day to perform alignment and keep 21 days from 00:00:00 to 23:59:59
dt_range
=
[
lim_date
-
timedelta
(
days
=
X
),
lim_date
-
timedelta
(
seconds
=
1
)]
data
=
data
.
drop
(
data
[
~
data
[
'date'
]
.
between
(
dt_range
[
0
],
dt_range
[
1
])]
.
index
,
axis
=
0
)
if
data
.
shape
[
0
]
>
((
X
*
24
*
60
)
/
int
(
resample_freq
[
0
:
2
]))
*
min_data
:
return
data
,
y
return
data
,
y
,
dt_range
else
:
return
None
else
:
...
...
@@ -588,13 +585,12 @@ for i_r, dic_func in enumerate([get_R1_dict]):
fill_value
=
1000
elif
order
[
i_r
]
==
'R4'
:
fill_value
=
code_dict
[
'-1'
]
X
=
[
apply_code_dict
(
x
[
0
]
.
copy
(
deep
=
True
),
code_dict
)
.
resample
(
resample_freq
,
on
=
'date'
,
convention
=
'end'
,
origin
=
'start_day'
)
.
mean
()
.
fillna
(
fill_value
)
for
x
in
life_cycles
if
x
is
not
None
]
X
=
np
.
array
([
apply_code_dict
(
x
[
0
],
code_dict
)
.
resample
(
resample_freq
,
on
=
'date'
)
.
mean
()
.
reindex
(
pd
.
date_range
(
start
=
x
[
2
][
0
],
end
=
x
[
2
][
1
],
freq
=
resample_freq
))
.
fillna
(
fill_value
)
.
values
for
x
in
life_cycles
if
x
is
not
None
],
dtype
=
'float'
)
y
=
np
.
asarray
([
x
[
1
]
for
x
in
life_cycles
if
x
is
not
None
])
.
astype
(
int
)
X
=
np
.
asarray
([
x
.
reindex
(
pd
.
date_range
(
start
=
x
.
index
[
-
1
]
.
date
()
-
timedelta
(
days
=
n_days
),
end
=
x
.
index
[
-
1
]
.
date
(),
freq
=
resample_freq
))
.
fillna
(
fill_value
)
.
values
for
x
in
X
])
print
(
X
.
shape
)
print
(
np
.
bincount
(
y
))
...
...
utils/__pycache__/classifications.cpython-38.pyc
View file @
1cf8d981
No preview for this file type
utils/__pycache__/representations.cpython-38.pyc
View file @
1cf8d981
No preview for this file type
utils/classifications.py
View file @
1cf8d981
...
...
@@ -154,8 +154,8 @@ class RISE(BaseEstimator, ClassifierMixin, SktimeEstimator):
class
Random_Forest
(
BaseEstimator
,
ClassifierMixin
):
def
__init__
(
self
,
n_estimators
=
3
00
,
max_depth
=
None
,
max_samples
=
0.7
5
,
ccp_alpha
=
0.022
5
,
class_weight
=
"balanced_subsample"
):
def
__init__
(
self
,
n_estimators
=
3
50
,
max_depth
=
None
,
max_samples
=
0.8
5
,
ccp_alpha
=
0.022
,
class_weight
=
"balanced_subsample"
):
self
.
n_estimators
=
n_estimators
self
.
max_depth
=
max_depth
self
.
max_samples
=
max_samples
...
...
utils/kernel_collection.npy
0 → 100644
View file @
1cf8d981
File added
utils/representations.py
View file @
1cf8d981
...
...
@@ -170,10 +170,11 @@ class MatrixProfile_transform():
return
self
class
ROCKET_transform
(
BaseEstimator
,
TransformerMixin
):
def
__init__
(
self
,
n_kernels
=
20000
,
kernel_sizes
=
(
5
,
7
,
9
,
11
),
flatten
=
False
):
def
__init__
(
self
,
n_kernels
=
20000
,
kernel_sizes
=
(
5
,
7
,
9
,
11
),
flatten
=
False
,
random_state
=
None
):
self
.
flatten
=
flatten
self
.
n_kernels
=
n_kernels
self
.
kernel_sizes
=
kernel_sizes
self
.
random_state
=
random_state
self
.
transformer
=
None
def
transform
(
self
,
X
,
y
=
None
):
...
...
@@ -186,7 +187,7 @@ class ROCKET_transform(BaseEstimator, TransformerMixin):
return
X
def
fit
(
self
,
X
,
y
=
None
):
self
.
transformer
=
ROCKET
(
n_kernels
=
self
.
n_kernels
,
kernel_sizes
=
self
.
kernel_sizes
)
self
.
transformer
=
ROCKET
(
n_kernels
=
self
.
n_kernels
,
kernel_sizes
=
self
.
kernel_sizes
,
random_state
=
self
.
random_state
)
X
=
X
.
reshape
(
X
.
shape
[
0
],
X
.
shape
[
1
])
self
.
transformer
.
fit
(
X
)
return
self
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment