Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bolsonaro
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
Luc Giffon
bolsonaro
Commits
125817c1
Commit
125817c1
authored
5 years ago
by
Charly Lamothe
Browse files
Options
Downloads
Patches
Plain Diff
Add back kmeans method in the trainer (disapeared during a merge)
parent
1db36b5d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!20
Resolve "integration-sota"
,
!19
WIP: Resolve "Adding new datasets"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/bolsonaro/trainer.py
+6
-4
6 additions, 4 deletions
code/bolsonaro/trainer.py
with
6 additions
and
4 deletions
code/bolsonaro/trainer.py
+
6
−
4
View file @
125817c1
...
@@ -96,7 +96,7 @@ class Trainer(object):
...
@@ -96,7 +96,7 @@ class Trainer(object):
self
.
_end_time
=
time
.
time
()
self
.
_end_time
=
time
.
time
()
def
__score_func
(
self
,
model
,
X
,
y_true
,
weights
=
True
):
def
__score_func
(
self
,
model
,
X
,
y_true
,
weights
=
True
):
if
type
(
model
)
in
[
OmpForestRegressor
,
RandomForestRegressor
,
SimilarityForestRegressor
]:
if
type
(
model
)
in
[
OmpForestRegressor
,
RandomForestRegressor
]:
if
weights
:
if
weights
:
y_pred
=
model
.
predict
(
X
)
y_pred
=
model
.
predict
(
X
)
else
:
else
:
...
@@ -109,12 +109,14 @@ class Trainer(object):
...
@@ -109,12 +109,14 @@ class Trainer(object):
y_pred
=
model
.
predict_no_weights
(
X
)
y_pred
=
model
.
predict_no_weights
(
X
)
if
type
(
model
)
is
OmpForestBinaryClassifier
:
if
type
(
model
)
is
OmpForestBinaryClassifier
:
y_pred
=
np
.
sign
(
y_pred
)
y_pred
=
np
.
sign
(
y_pred
)
y_pred
=
np
.
where
(
y_pred
==
0
,
1
,
y_pred
)
y_pred
=
np
.
where
(
y_pred
==
0
,
1
,
y_pred
)
result
=
self
.
_classification_score_metric
(
y_true
,
y_pred
)
result
=
self
.
_classification_score_metric
(
y_true
,
y_pred
)
elif
type
(
model
)
in
[
SimilarityForestRegressor
,
KMeansForestRegressor
]:
result
=
model
.
score
(
X
,
y_true
)
return
result
return
result
def
__score_func_base
(
self
,
model
,
X
,
y_true
):
def
__score_func_base
(
self
,
model
,
X
,
y_true
):
if
type
(
model
)
==
OmpForestRegressor
:
if
type
(
model
)
in
[
OmpForestRegressor
,
SimilarityForestRegressor
,
KMeansForestRegressor
]
:
y_pred
=
model
.
predict_base_estimator
(
X
)
y_pred
=
model
.
predict_base_estimator
(
X
)
result
=
self
.
_base_regression_score_metric
(
y_true
,
y_pred
)
result
=
self
.
_base_regression_score_metric
(
y_true
,
y_pred
)
elif
type
(
model
)
in
[
OmpForestBinaryClassifier
,
OmpForestMulticlassClassifier
]:
elif
type
(
model
)
in
[
OmpForestBinaryClassifier
,
OmpForestMulticlassClassifier
]:
...
@@ -123,7 +125,7 @@ class Trainer(object):
...
@@ -123,7 +125,7 @@ class Trainer(object):
elif
type
(
model
)
==
RandomForestClassifier
:
elif
type
(
model
)
==
RandomForestClassifier
:
y_pred
=
model
.
predict
(
X
)
y_pred
=
model
.
predict
(
X
)
result
=
self
.
_base_classification_score_metric
(
y_true
,
y_pred
)
result
=
self
.
_base_classification_score_metric
(
y_true
,
y_pred
)
elif
type
(
model
)
i
n
[
RandomForestRegressor
,
SimilarityForestRegressor
]
:
elif
type
(
model
)
i
s
RandomForestRegressor
:
y_pred
=
model
.
predict
(
X
)
y_pred
=
model
.
predict
(
X
)
result
=
self
.
_base_regression_score_metric
(
y_true
,
y_pred
)
result
=
self
.
_base_regression_score_metric
(
y_true
,
y_pred
)
return
result
return
result
...
...
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