Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scikit-luc
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Luc Giffon
scikit-luc
Commits
6344c6f0
Commit
6344c6f0
authored
6 years ago
by
Luc Giffon
Browse files
Options
Downloads
Patches
Plain Diff
solve normalization problem, add min and max property to dataset
parent
16c2c1cd
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
skluc/main/data/mldatasets/Dataset.py
+11
-2
11 additions, 2 deletions
skluc/main/data/mldatasets/Dataset.py
skluc/test/test_data/test_mldatasets/TestDataset.py
+14
-0
14 additions, 0 deletions
skluc/test/test_data/test_mldatasets/TestDataset.py
with
25 additions
and
2 deletions
skluc/main/data/mldatasets/Dataset.py
+
11
−
2
View file @
6344c6f0
...
@@ -34,6 +34,14 @@ class Dataset(object):
...
@@ -34,6 +34,14 @@ class Dataset(object):
self
.
permuted_index_validation
=
None
self
.
permuted_index_validation
=
None
self
.
validation_size
=
validation_size
self
.
validation_size
=
validation_size
@property
def
min
(
self
):
return
np
.
min
(
self
.
train
.
data
)
@property
def
max
(
self
):
return
np
.
max
(
self
.
train
.
data
)
def
reduce_data_size
(
self
,
new_size
):
def
reduce_data_size
(
self
,
new_size
):
logger
.
info
(
"
Reducing datasize of dataset {} to .
"
.
format
(
self
.
s_name
,
new_size
))
logger
.
info
(
"
Reducing datasize of dataset {} to .
"
.
format
(
self
.
s_name
,
new_size
))
kept_indices
=
self
.
get_uniform_class_rand_indices_train
(
new_size
)
kept_indices
=
self
.
get_uniform_class_rand_indices_train
(
new_size
)
...
@@ -217,8 +225,9 @@ class Dataset(object):
...
@@ -217,8 +225,9 @@ class Dataset(object):
if
len
(
datlab
.
labels
)
==
0
:
if
len
(
datlab
.
labels
)
==
0
:
continue
continue
data
=
datlab
.
data
data
=
datlab
.
data
_min
=
data
.
min
()
_min
=
self
.
min
_max
=
data
.
max
()
_max
=
self
.
max
logger
.
debug
(
f
"
Minimum value of train set is
{
_min
}
; max is
{
_max
}
"
)
data
=
(
data
-
_min
)
/
(
_max
-
_min
)
data
=
(
data
-
_min
)
/
(
_max
-
_min
)
logger
.
debug
(
"
Apply normalization to {} data of {} dataset.
"
.
format
(
kw
,
self
.
s_name
))
logger
.
debug
(
"
Apply normalization to {} data of {} dataset.
"
.
format
(
kw
,
self
.
s_name
))
setattr
(
self
,
kw
,
LabeledData
(
data
,
datlab
.
labels
))
setattr
(
self
,
kw
,
LabeledData
(
data
,
datlab
.
labels
))
...
...
This diff is collapsed.
Click to expand it.
skluc/test/test_data/test_mldatasets/TestDataset.py
+
14
−
0
View file @
6344c6f0
...
@@ -24,6 +24,20 @@ class TestDataset(unittest.TestCase):
...
@@ -24,6 +24,20 @@ class TestDataset(unittest.TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
dataset_classes
=
[
FooDataset
]
self
.
dataset_classes
=
[
FooDataset
]
def
test_min_max
(
self
):
for
d_class
in
self
.
dataset_classes
:
d1
=
d_class
(
validation_size
=
1000
,
seed
=
0
)
d1
.
load
()
mini_train
=
np
.
min
(
d1
.
train
.
data
)
maxi_train
=
np
.
max
(
d1
.
train
.
data
)
self
.
assertEqual
(
mini_train
,
d1
.
min
)
self
.
assertEqual
(
maxi_train
,
d1
.
max
)
mini_test
=
np
.
min
(
d1
.
test
.
data
)
maxi_test
=
np
.
max
(
d1
.
test
.
data
)
self
.
assertNotEquals
(
mini_test
,
d1
.
min
)
self
.
assertNotEquals
(
maxi_test
,
d1
.
max
)
def
test_seed_train_val
(
self
):
def
test_seed_train_val
(
self
):
for
d_class
in
self
.
dataset_classes
:
for
d_class
in
self
.
dataset_classes
:
d1
=
d_class
(
validation_size
=
1000
,
seed
=
0
)
d1
=
d_class
(
validation_size
=
1000
,
seed
=
0
)
...
...
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