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
2bc656f5
Commit
2bc656f5
authored
5 years ago
by
dmt
Browse files
Options
Downloads
Patches
Plain Diff
Assign an id starting from 1 on every tier.
parent
dd250778
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cml/domain/deconstruction.py
+18
-8
18 additions, 8 deletions
cml/domain/deconstruction.py
cml/domain/reconstruction.py
+8
-9
8 additions, 9 deletions
cml/domain/reconstruction.py
with
26 additions
and
17 deletions
cml/domain/deconstruction.py
+
18
−
8
View file @
2bc656f5
...
...
@@ -111,9 +111,10 @@ class KnowledgeDatabase(ABC):
def
serialize
(
self
):
pass
def
generate_free_ids
(
self
):
for
i
in
count
(
1
):
yield
i
def
model_counter
(
self
):
def
counts
(
tier
):
return
self
.
database
[
tier
].
biggest_id
+
1
return
counts
def
remove_dependent_models
(
self
,
relative_model
:
PragmaticMachineLearningModel
):
...
...
@@ -139,12 +140,14 @@ class KnowledgeDomain:
def
__init__
(
self
,
tier
:
int
):
self
.
tier
=
tier
self
.
knowledge
=
{}
self
.
biggest_id
=
0
def
get
(
self
,
uid
:
str
):
return
self
.
knowledge
[
uid
]
def
insert
(
self
,
model
:
PragmaticMachineLearningModel
):
self
.
knowledge
[
model
]
=
model
self
.
update_biggest_id
(
model
.
counter
)
def
remove
(
self
,
model
:
PragmaticMachineLearningModel
):
del
self
.
knowledge
[
model
]
...
...
@@ -154,6 +157,10 @@ class KnowledgeDomain:
replacer
:
PragmaticMachineLearningModel
):
del
self
.
knowledge
[
replaced
]
self
.
knowledge
[
replacer
]
=
replacer
self
.
update_biggest_id
(
replacer
.
counter
)
def
update_biggest_id
(
self
,
new_id
):
self
.
biggest_id
=
max
(
self
.
biggest_id
,
new_id
)
class
RelativeFinder
:
...
...
@@ -251,6 +258,7 @@ class Deconstructor:
TIME_COLUMN
=
"
T
"
SUBJECT_COLUMN
=
"
Sigma
"
PURPOSE_COLUMN
=
"
Z
"
NEXT_MODEL_COUNTER
=
None
def
__init__
(
self
,
knowledge_database
:
KnowledgeDatabase
,
...
...
@@ -377,8 +385,8 @@ class Deconstructor:
if
over_block
.
rows
>=
self
.
settings
.
learn_block_minimum
:
# Create new metadata for a pragmatic model
new_model
=
prag_model
.
fusion
(
relative_model
,
next
(
self
.
free_id
))
new_model
=
prag_model
.
fusion
(
relative_model
,
self
.
NEXT_MODEL_COUNTER
(
tier
))
# Which models should be used for the reconstruction
which_ml_models
=
new_model
.
sigma
...
...
@@ -422,7 +430,8 @@ class Deconstructor:
if
overlapping_block
.
rows
>=
2
:
# Model fusion
new_model
=
p_model
.
fusion
(
r_model
,
next
(
self
.
free_id
))
new_model
=
p_model
.
fusion
(
r_model
,
self
.
NEXT_MODEL_COUNTER
(
tier
))
which_ml_models
=
new_model
.
sigma
# Get learnblock
...
...
@@ -502,7 +511,8 @@ class Deconstructor:
try
:
# Check feature intersection constraint
if
r_model
and
self
.
_feature_intersection
(
p_model
,
r_model
)
>=
2
:
new_model
=
p_model
.
fusion
(
r_model
,
next
(
self
.
free_id
))
new_model
=
p_model
.
fusion
(
r_model
,
self
.
NEXT_MODEL_COUNTER
(
tier
))
# Check time contraint
elif
r_model
and
self
.
time_constraint
(
p_model
,
r_model
,
"
complete
"
):
...
...
@@ -514,7 +524,7 @@ class Deconstructor:
which_ml_models
=
p_model
.
subject
+
r_model
.
subject
self
.
reconstructor
.
reconstruct
(
tier
,
ts_relatives
,
which_ml_models
)
new_model
=
p_model
.
fusion
(
r_model
,
next
(
self
.
free_id
))
new_model
=
p_model
.
fusion
(
r_model
,
self
.
NEXT_MODEL_COUNTER
(
tier
))
else
:
return
# Create learnblock
...
...
This diff is collapsed.
Click to expand it.
cml/domain/reconstruction.py
+
8
−
9
View file @
2bc656f5
...
...
@@ -123,6 +123,10 @@ class PragmaticMachineLearningModel:
str
(
self
.
meta
.
knowledge_tier
),
str
(
self
.
meta
.
identifier
)])
@property
def
counter
(
self
):
return
self
.
meta
.
identifier
def
fusion
(
self
,
model
:
'
PragmaticMachineLearningModel
'
,
new_identifier
:
int
)
->
Metadata
:
...
...
@@ -159,6 +163,9 @@ def log(func):
class
Reconstructor
:
CONCEPTUAL_KNOWLEDGE_ABBREVIATION
=
"
C
"
NEXT_MODEL_COUNTER
=
None
def
__init__
(
self
,
settings
:
ReconstructionSettings
,
ml_models
:
List
,
...
...
@@ -168,7 +175,7 @@ class Reconstructor:
self
.
knowledge_domain
=
knowlege_domain
self
.
logger
=
None
self
.
_category
=
None
self
.
_
free_id
=
None
self
.
free_id
=
None
self
.
__reconstruction
=
None
@property
...
...
@@ -186,14 +193,6 @@ class Reconstructor:
else
:
raise
ValueError
()
self
.
_category
=
value
@property
def
free_id
(
self
)
->
Generator
[
int
,
None
,
None
]:
return
self
.
_free_id
@free_id.setter
def
free_id
(
self
,
value
:
Generator
[
int
,
None
,
None
])
->
None
:
self
.
_free_id
=
iter
(
value
)
@log
def
reconstruct
(
self
,
tier
:
int
,
...
...
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