Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Leipzig Machine Learning Group
conML
python
Commits
0319d03d
Commit
0319d03d
authored
5 years ago
by
dmt
Browse files
Options
Downloads
Patches
Plain Diff
Define the DataSource, Preprocessor and LearnblockIdentifier.
parent
72a917b8
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
cml/domain/data_source.py
+59
-0
59 additions, 0 deletions
cml/domain/data_source.py
with
59 additions
and
0 deletions
cml/domain/data_source.py
0 → 100644
+
59
−
0
View file @
0319d03d
from
os.path
import
commonprefix
__all__
=
(
"
DataSource
"
,
"
Preprocessor
"
,
"
LearnblockIdentifier
"
)
class
DataSource
:
def
__init__
(
self
,
source
,
learnblock_identifier
):
self
.
source
=
source
self
.
learnblock_identifier
=
learnblock_identifier
class
Preprocessor
:
TARGET_COLUMN
=
"
Z
"
TIME_COLUMN
=
"
T
"
def
__init__
(
self
,
settings
):
self
.
settings
=
settings
def
clean
(
self
,
table
):
self
.
_drop_irrelevant_columns
(
table
)
if
self
.
settings
.
set_targets
:
self
.
_overwrite_target_column
(
table
)
if
self
.
settings
.
sort_time_stamp
:
self
.
_sort_according_time_stamp
(
table
)
if
self
.
settings
.
cut_time_stamp
:
self
.
_remove_common_time_stamp_prefix
(
table
)
def
_drop_irrelevant_columns
(
self
,
table
):
# TODO (dmt): Don't drop T, Z and Sigma columns!
for
column
in
table
.
get_columns
():
column_index
=
table
.
get_column_index_by_name
(
column
)
if
column_index
not
in
self
.
settings
.
set_features
:
table
.
drop_column_by_index
(
column_index
)
def
_overwrite_target_column
(
self
,
table
):
table
.
set_column_value
(
self
.
TARGET_COLUMN
,
self
.
settings
.
set_targets
)
def
_sort_according_time_stamp
(
self
,
table
):
table
.
sort
(
self
.
TIME_COLUMN
)
def
_remove_common_time_stamp_prefix
(
self
,
table
):
# TODO (dmt): Check if timestamp column is of type string!
time_column
=
table
.
get_column_values_as_list
(
self
.
TIME_COLUMN
)
common_prefix
=
commonprefix
(
time_column
)
cleaned_time_column
=
[
s
.
lstrip
(
common_prefix
)
for
s
in
time_column
]
table
.
set_column_values
(
cleaned_time_column
)
class
LearnblockIdentifier
:
def
__init__
(
self
,
settings
):
self
.
settings
=
settings
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