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
bef24bd4
Commit
bef24bd4
authored
5 years ago
by
dmt
Browse files
Options
Downloads
Patches
Plain Diff
Construct only unlabeled learnblocks.
parent
2fc6a3d7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cml/domain/construction.py
+33
-24
33 additions, 24 deletions
cml/domain/construction.py
with
33 additions
and
24 deletions
cml/domain/construction.py
+
33
−
24
View file @
bef24bd4
...
@@ -42,6 +42,7 @@ class Constructor:
...
@@ -42,6 +42,7 @@ class Constructor:
self
.
ml_models
=
ml_models
self
.
ml_models
=
ml_models
self
.
_logging_dir
=
None
self
.
_logging_dir
=
None
self
.
_construction
=
None
self
.
_construction
=
None
self
.
_category
=
None
@log_construction
@log_construction
def
construct
(
self
,
learnblock
):
def
construct
(
self
,
learnblock
):
...
@@ -86,10 +87,10 @@ class Constructor:
...
@@ -86,10 +87,10 @@ class Constructor:
@property
@property
def
construction_type
(
self
):
def
construction_type
(
self
):
return
self
.
settings
.
construct_type
return
self
.
_category
@construction_type.setter
@construction_type.setter
def
construction_type
(
self
,
construct_type
):
def
construction_type
(
self
,
construct
ion
_type
):
if
self
.
settings
.
construct_type
==
"
conceptual
"
:
if
self
.
settings
.
construct_type
==
"
conceptual
"
:
self
.
_construction
=
partial
(
self
.
_construction
=
partial
(
self
.
_construct_conceptual_knowledge
,
self
.
_construct_conceptual_knowledge
,
...
@@ -108,34 +109,42 @@ class Constructor:
...
@@ -108,34 +109,42 @@ class Constructor:
# TODO (dmt): Provide proper exception handling.
# TODO (dmt): Provide proper exception handling.
raise
Exception
(
"
Provide valid construction type.
"
)
raise
Exception
(
"
Provide valid construction type.
"
)
self
.
_category
=
construction_type
def
_construct_conceptual_knowledge
(
self
,
def
_construct_conceptual_knowledge
(
self
,
learnblock
,
learnblock
,
categorial_complexity
=
None
,
categorial_complexity
=
None
,
min_category_size
=
None
):
min_category_size
=
None
):
for
ml_model
in
self
.
ml_models
:
if
learnblock
.
labeled
:
for
cluster_number
in
range
(
2
,
categorial_complexity
+
1
):
yield
learnblock
ml_model
.
cluster
=
cluster_number
else
:
trained_model
=
ml_model
.
train
(
learnblock
)
for
ml_model
in
self
.
ml_models
:
for
cluster
,
size
in
trained_model
.
cluster_sizes
.
items
():
for
cluster_number
in
range
(
2
,
categorial_complexity
+
1
):
if
size
<
min_category_size
:
ml_model
.
cluster
=
cluster_number
continue
trained_model
=
ml_model
.
train
(
learnblock
)
labels
=
trained_model
.
get_labels
()
for
cluster
,
size
in
trained_model
.
cluster_sizes
.
items
():
labeled_learnblock
=
learnblock
.
set_labels
(
labels
)
if
size
<
min_category_size
:
labeled_learnblock
.
n_cluster
=
cluster_number
continue
yield
labeled_learnblock
labels
=
trained_model
.
get_labels
()
labeled_learnblock
=
learnblock
.
set_labels
(
labels
)
labeled_learnblock
.
n_cluster
=
cluster_number
yield
labeled_learnblock
def
_construct_procedural_knowledge
(
self
,
def
_construct_procedural_knowledge
(
self
,
learnblock
,
learnblock
,
procedural_complexity
=
None
,
procedural_complexity
=
None
,
max_target_error
=
None
):
max_target_error
=
None
):
for
ml_model
in
self
.
ml_models
:
if
learnblock
.
labeled
:
for
target_number
in
range
(
2
,
procedural_complexity
+
1
):
yield
learnblock
model
=
ml_model
()
else
:
model
.
io_shape
=
learnblock
.
learn_rows
for
ml_model
in
self
.
ml_models
:
model
.
target_number
=
target_number
for
target_number
in
range
(
2
,
procedural_complexity
+
1
):
trained_model
=
model
.
train
(
learnblock
.
as_numpy_array
())
model
=
ml_model
()
if
trained_model
.
target_error
<
max_target_error
:
model
.
io_shape
=
learnblock
.
learn_rows
for
labels
in
trained_model
.
targets
:
model
.
target_number
=
target_number
labeled_learnblock
=
learnblock
.
set_labels
(
list
(
labels
))
trained_model
=
model
.
train
(
learnblock
.
as_numpy_array
())
labeled_learnblock
.
n_cluster
=
target_number
if
trained_model
.
target_error
<
max_target_error
:
yield
labeled_learnblock
for
labels
in
trained_model
.
targets
:
labeled_learnblock
=
learnblock
.
set_labels
(
list
(
labels
))
labeled_learnblock
.
n_cluster
=
target_number
yield
labeled_learnblock
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