Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
KerasROOTClassification
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
Eric.Schanet
KerasROOTClassification
Commits
778a981d
Commit
778a981d
authored
6 years ago
by
Nikolai Hartmann
Browse files
Options
Downloads
Patches
Plain Diff
scale and shift example data for tests randomly
parent
7d32696b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_toolkit.py
+14
-0
14 additions, 0 deletions
test/test_toolkit.py
with
14 additions
and
0 deletions
test/test_toolkit.py
+
14
−
0
View file @
778a981d
...
@@ -8,12 +8,22 @@ from keras.layers import GRU
...
@@ -8,12 +8,22 @@ from keras.layers import GRU
from
KerasROOTClassification
import
ClassificationProject
,
ClassificationProjectRNN
from
KerasROOTClassification
import
ClassificationProject
,
ClassificationProjectRNN
def
create_dataset
(
path
):
def
create_dataset
(
path
):
# create example dataset with (low-weighted) noise added
X
,
y
=
make_classification
(
n_samples
=
10000
,
random_state
=
1
)
X
,
y
=
make_classification
(
n_samples
=
10000
,
random_state
=
1
)
X2
=
np
.
random
.
normal
(
size
=
20
*
10000
).
reshape
(
-
1
,
20
)
X2
=
np
.
random
.
normal
(
size
=
20
*
10000
).
reshape
(
-
1
,
20
)
y2
=
np
.
concatenate
([
np
.
zeros
(
5000
),
np
.
ones
(
5000
)])
y2
=
np
.
concatenate
([
np
.
zeros
(
5000
),
np
.
ones
(
5000
)])
X
=
np
.
concatenate
([
X
,
X2
])
X
=
np
.
concatenate
([
X
,
X2
])
y
=
np
.
concatenate
([
y
,
y2
])
y
=
np
.
concatenate
([
y
,
y2
])
w
=
np
.
concatenate
([
np
.
ones
(
10000
),
0.01
*
np
.
ones
(
10000
)])
w
=
np
.
concatenate
([
np
.
ones
(
10000
),
0.01
*
np
.
ones
(
10000
)])
# shift and scale randomly (to check if transformation is working)
shift
=
np
.
random
.
rand
(
20
)
*
100
scale
=
np
.
random
.
rand
(
20
)
*
1000
X
*=
scale
X
+=
shift
# write to root files
branches
=
[
"
var_{}
"
.
format
(
i
)
for
i
in
range
(
len
(
X
[
0
]))]
branches
=
[
"
var_{}
"
.
format
(
i
)
for
i
in
range
(
len
(
X
[
0
]))]
df
=
pd
.
DataFrame
(
X
,
columns
=
branches
)
df
=
pd
.
DataFrame
(
X
,
columns
=
branches
)
df
[
"
class
"
]
=
y
df
[
"
class
"
]
=
y
...
@@ -41,6 +51,8 @@ def test_ClassificationProject(tmp_path):
...
@@ -41,6 +51,8 @@ def test_ClassificationProject(tmp_path):
nodes
=
128
,
nodes
=
128
,
)
)
c
.
train
(
epochs
=
200
)
c
.
train
(
epochs
=
200
)
c
.
plot_all_inputs
()
c
.
plot_loss
()
assert
min
(
c
.
history
.
history
[
"
val_loss
"
])
<
0.18
assert
min
(
c
.
history
.
history
[
"
val_loss
"
])
<
0.18
...
@@ -71,4 +83,6 @@ def test_ClassificationProjectRNN(tmp_path):
...
@@ -71,4 +83,6 @@ def test_ClassificationProjectRNN(tmp_path):
)
)
assert
sum
([
isinstance
(
layer
,
GRU
)
for
layer
in
c
.
model
.
layers
])
==
2
assert
sum
([
isinstance
(
layer
,
GRU
)
for
layer
in
c
.
model
.
layers
])
==
2
c
.
train
(
epochs
=
200
)
c
.
train
(
epochs
=
200
)
c
.
plot_all_inputs
()
c
.
plot_loss
()
assert
min
(
c
.
history
.
history
[
"
val_loss
"
])
<
0.18
assert
min
(
c
.
history
.
history
[
"
val_loss
"
])
<
0.18
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