Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scikit-splearn
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dev
scikit-splearn
Commits
e78e3959
There was a problem fetching the pipeline summary.
Commit
e78e3959
authored
7 years ago
by
Denis.Arrivault
Browse files
Options
Downloads
Patches
Plain Diff
Update optimization tests
parent
f14ae87c
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
splearn/spectral.py
+123
-43
123 additions, 43 deletions
splearn/spectral.py
with
123 additions
and
43 deletions
splearn/spectral.py
+
123
−
43
View file @
e78e3959
...
@@ -42,6 +42,9 @@ from __future__ import division, print_function
...
@@ -42,6 +42,9 @@ from __future__ import division, print_function
import
numpy
as
np
import
numpy
as
np
import
math
import
math
import
warnings
import
warnings
import
threading
lock
=
threading
.
RLock
()
from
splearn.datasets.data_sample
import
SplearnArray
from
splearn.datasets.data_sample
import
SplearnArray
from
splearn.hankel
import
Hankel
from
splearn.hankel
import
Hankel
...
@@ -288,13 +291,89 @@ class Spectral(BaseEstimator):
...
@@ -288,13 +291,89 @@ class Spectral(BaseEstimator):
lcolumnsmax
=
self
.
lcolumns
.
__len__
()
lcolumnsmax
=
self
.
lcolumns
.
__len__
()
version_columns_int
=
False
version_columns_int
=
False
lmax
=
lrowsmax
+
lcolumnsmax
lmax
=
lrowsmax
+
lcolumnsmax
#threads = []
for
line
in
range
(
X
.
shape
[
0
]):
for
line
in
range
(
X
.
shape
[
0
]):
self
.
_populate_a_word
(
X
,
line
,
lrowsmax
,
version_rows_int
,
lcolumnsmax
,
version_columns_int
,
lmax
)
self
.
_populate_a_word
(
X
,
line
,
lrowsmax
,
version_rows_int
,
lcolumnsmax
,
version_columns_int
,
lmax
)
# )
# threads.append(threading.Thread(target = self._populate_a_word,
# args=(X, line, lrowsmax, version_rows_int,
# lcolumnsmax, version_columns_int, lmax)
# ).start())
else
:
else
:
for
line
in
range
(
X
.
shape
[
0
]):
for
line
in
range
(
X
.
shape
[
0
]):
self
.
_populate_a_word
(
X
,
line
)
self
.
_populate_a_word
(
X
,
line
)
return
X
return
X
def
_populate_a_word_locked
(
self
,
X
,
line
,
lrowsmax
=
None
,
version_rows_int
=
None
,
lcolumnsmax
=
None
,
version_columns_int
=
None
,
lmax
=
None
):
w
=
X
[
line
,
:]
w
=
w
[
w
>=
0
]
w
=
tuple
([
int
(
x
)
for
x
in
w
[
0
:]])
X
.
sample
[
w
]
=
X
.
sample
.
setdefault
(
w
,
0
)
+
1
if
self
.
version
==
"
prefix
"
or
self
.
version
==
"
classic
"
:
# empty word treatment for prefixe, suffix, and factor dictionnaries
with
lock
:
X
.
pref
[()]
=
X
.
pref
.
setdefault
((),
0
)
+
1
if
self
.
version
==
"
suffix
"
or
self
.
version
==
"
classic
"
:
with
lock
:
X
.
suff
[()]
=
X
.
suff
.
setdefault
((),
0
)
+
1
if
(
self
.
version
==
"
factor
"
or
self
.
version
==
"
suffix
"
or
self
.
version
==
"
prefix
"
):
with
lock
:
X
.
fact
[()]
=
X
.
fact
.
setdefault
((),
0
)
+
len
(
w
)
+
1
if
self
.
partial
:
for
i
in
range
(
len
(
w
)):
if
self
.
version
==
"
classic
"
:
if
((
version_rows_int
and
i
+
1
<=
lrowsmax
)
or
(
not
version_rows_int
and
w
[:
i
+
1
]
in
self
.
lrows
)):
with
lock
:
X
.
pref
[
w
[:
i
+
1
]]
=
X
.
pref
.
setdefault
(
w
[:
i
+
1
],
0
)
+
1
if
((
version_columns_int
and
i
+
1
<=
lcolumnsmax
)
or
(
not
version_columns_int
and
w
[
-
(
i
+
1
):]
in
self
.
lcolumns
)):
with
lock
:
X
.
suff
[
w
[
-
(
i
+
1
):]]
=
X
.
suff
.
setdefault
(
w
[
-
(
i
+
1
):],
0
)
+
1
elif
self
.
version
==
"
prefix
"
:
# dictionaries dpref is populated until
# lmax = lrows + lcolumns
# dictionaries dfact is populated until lcolumns
if
(((
version_rows_int
or
version_columns_int
)
and
i
+
1
<=
lmax
)
or
(
not
version_rows_int
and
w
[:
i
+
1
]
in
self
.
lrows
)
or
(
not
version_columns_int
and
w
[:
i
+
1
]
in
self
.
lcolumns
)):
with
lock
:
X
.
pref
[
w
[:
i
+
1
]]
=
X
.
pref
.
setdefault
(
w
[:
i
+
1
],
0
)
+
1
for
j
in
range
(
i
+
1
,
len
(
w
)
+
1
):
if
((
version_columns_int
and
(
j
-
i
)
<=
lmax
)
or
(
not
version_columns_int
and
w
[
i
:
j
]
in
self
.
lcolumns
)):
with
lock
:
X
.
fact
[
w
[
i
:
j
]]
=
X
.
fact
.
setdefault
(
w
[
i
:
j
],
0
)
+
1
elif
self
.
version
==
"
suffix
"
:
if
(((
version_rows_int
or
version_columns_int
)
and
i
<=
lmax
)
or
(
not
version_rows_int
and
w
[
-
(
i
+
1
):]
in
self
.
lrows
)
or
(
not
version_columns_int
and
w
[
-
(
i
+
1
):]
in
self
.
lcolumns
)):
with
lock
:
X
.
suff
[
w
[
-
(
i
+
1
):]]
=
X
.
suff
.
setdefault
(
w
[
-
(
i
+
1
):],
0
)
+
1
for
j
in
range
(
i
+
1
,
len
(
w
)
+
1
):
if
((
version_rows_int
and
(
j
-
i
)
<=
lmax
)
or
(
not
version_rows_int
and
w
[
i
:
j
]
in
self
.
lrows
)):
with
lock
:
X
.
fact
[
w
[
i
:
j
]]
=
X
.
fact
.
setdefault
(
w
[
i
:
j
],
0
)
+
1
elif
self
.
version
==
"
factor
"
:
for
j
in
range
(
i
+
1
,
len
(
w
)
+
1
):
if
(((
version_rows_int
or
version_columns_int
)
and
(
j
-
i
)
<=
lmax
)
or
(
not
version_rows_int
and
w
[
i
:
j
]
in
self
.
lrows
)
or
(
not
version_columns_int
and
w
[
i
:
j
]
in
self
.
lcolumns
)):
with
lock
:
X
.
fact
[
w
[
i
:
j
]]
=
X
.
fact
.
setdefault
(
w
[
i
:
j
],
0
)
+
1
else
:
# not partial
for
i
in
range
(
len
(
w
)):
with
lock
:
X
.
pref
[
w
[:
i
+
1
]]
=
X
.
pref
.
setdefault
(
w
[:
i
+
1
],
0
)
+
1
X
.
suff
[
w
[
i
:]]
=
X
.
suff
.
setdefault
(
w
[
i
:],
0
)
+
1
for
j
in
range
(
i
+
1
,
len
(
w
)
+
1
):
with
lock
:
X
.
fact
[
w
[
i
:
j
]]
=
X
.
fact
.
setdefault
(
w
[
i
:
j
],
0
)
+
1
def
_populate_a_word
(
self
,
X
,
line
,
lrowsmax
=
None
,
version_rows_int
=
None
,
def
_populate_a_word
(
self
,
X
,
line
,
lrowsmax
=
None
,
version_rows_int
=
None
,
lcolumnsmax
=
None
,
version_columns_int
=
None
,
lmax
=
None
):
lcolumnsmax
=
None
,
version_columns_int
=
None
,
lmax
=
None
):
w
=
X
[
line
,
:]
w
=
X
[
line
,
:]
...
@@ -352,6 +431,7 @@ class Spectral(BaseEstimator):
...
@@ -352,6 +431,7 @@ class Spectral(BaseEstimator):
for
j
in
range
(
i
+
1
,
len
(
w
)
+
1
):
for
j
in
range
(
i
+
1
,
len
(
w
)
+
1
):
X
.
fact
[
w
[
i
:
j
]]
=
X
.
fact
.
setdefault
(
w
[
i
:
j
],
0
)
+
1
X
.
fact
[
w
[
i
:
j
]]
=
X
.
fact
.
setdefault
(
w
[
i
:
j
],
0
)
+
1
def
polulate_dictionnaries
(
self
,
X
):
def
polulate_dictionnaries
(
self
,
X
):
"""
Populates the *sample*, *pref*, *suff*, *fact* dictionnaries of X
"""
Populates the *sample*, *pref*, *suff*, *fact* dictionnaries of X
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment