Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Luc Giffon
bolsonaro
Commits
c43ae6c4
Commit
c43ae6c4
authored
Mar 11, 2020
by
Charly Lamothe
Browse files
Add few stage5 results, code fixes and begins to caught warnings
parent
5d348f2e
Changes
8
Hide whitespace changes
Inline
Side-by-side
code/bolsonaro/models/ensemble_selection_forest_regressor.py
View file @
c43ae6c4
...
...
@@ -52,7 +52,7 @@ class EnsembleSelectionForestRegressor(BaseEstimator, metaclass=ABCMeta):
del
class_list
[
candidate_index
]
def
score
(
self
,
X
,
y
):
predictions
=
self
.
_
predict_base_estimator
(
X
)
predictions
=
self
.
predict_base_estimator
(
X
)
return
self
.
_score_metric
(
predictions
,
y
)
def
predict_base_estimator
(
self
,
X
):
...
...
code/bolsonaro/models/omp_forest.py
View file @
c43ae6c4
...
...
@@ -5,6 +5,7 @@ from abc import abstractmethod, ABCMeta
import
numpy
as
np
from
sklearn.linear_model
import
OrthogonalMatchingPursuit
from
sklearn.base
import
BaseEstimator
import
warnings
class
OmpForest
(
BaseEstimator
,
metaclass
=
ABCMeta
):
...
...
@@ -109,7 +110,17 @@ class SingleOmpForest(OmpForest):
super
().
__init__
(
models_parameters
,
base_forest_estimator
)
def
fit_omp
(
self
,
atoms
,
objective
):
self
.
_omp
.
fit
(
atoms
,
objective
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
caught_warnings
:
# Cause all warnings to always be triggered.
warnings
.
simplefilter
(
"always"
)
self
.
_omp
.
fit
(
atoms
,
objective
)
# ignore any non-custom warnings that may be in the list
caught_warnings
=
list
(
filter
(
lambda
i
:
i
.
message
!=
RuntimeWarning
(
omp_premature_warning
),
caught_warnings
))
if
len
(
caught_warnings
)
>
0
:
logger
.
error
(
f
'number of linear dependences in the dictionary:
{
len
(
caught_warnings
)
}
. model parameters:
{
str
(
self
.
_models_parameters
.
__dict__
)
}
'
)
def
predict
(
self
,
X
):
"""
...
...
code/bolsonaro/models/omp_forest_classifier.py
View file @
c43ae6c4
from
bolsonaro.models.omp_forest
import
OmpForest
,
SingleOmpForest
from
bolsonaro.utils
import
binarize_class_data
from
bolsonaro.utils
import
binarize_class_data
,
omp_premature_warning
import
numpy
as
np
from
sklearn.ensemble
import
RandomForestClassifier
from
sklearn.linear_model
import
OrthogonalMatchingPursuit
import
warnings
class
OmpForestBinaryClassifier
(
SingleOmpForest
):
...
...
@@ -92,7 +93,19 @@ class OmpForestMulticlassClassifier(OmpForest):
omp_class
=
OrthogonalMatchingPursuit
(
n_nonzero_coefs
=
self
.
models_parameters
.
extracted_forest_size
,
fit_intercept
=
True
,
normalize
=
False
)
omp_class
.
fit
(
atoms_binary
,
objective_binary
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
caught_warnings
:
# Cause all warnings to always be triggered.
warnings
.
simplefilter
(
"always"
)
omp_class
.
fit
(
atoms_binary
,
objective_binary
)
# ignore any non-custom warnings that may be in the list
caught_warnings
=
list
(
filter
(
lambda
i
:
i
.
message
!=
RuntimeWarning
(
omp_premature_warning
),
caught_warnings
))
if
len
(
caught_warnings
)
>
0
:
logger
.
error
(
f
'number of linear dependences in the dictionary:
{
len
(
caught_warnings
)
}
. model parameters:
{
str
(
self
.
_models_parameters
.
__dict__
)
}
'
)
self
.
_dct_class_omp
[
class_label
]
=
omp_class
return
self
.
_dct_class_omp
...
...
code/bolsonaro/utils.py
View file @
c43ae6c4
...
...
@@ -124,3 +124,7 @@ def is_float(value):
return
True
except
ValueError
:
return
False
omp_premature_warning
=
""" Orthogonal matching pursuit ended prematurely due to linear
dependence in the dictionary. The requested precision might not have been met.
"""
results/boston/stage5/losses_base-random-omp-omp_without_weights-kmeans.png
0 → 100644
View file @
c43ae6c4
64 KB
results/diabetes/stage5/losses_base-random-omp-omp_without_weights-kmeans.png
0 → 100644
View file @
c43ae6c4
63.2 KB
results/diabetes/stage5/losses_base-random-omp-omp_without_weights-similarity.png
0 → 100644
View file @
c43ae6c4
57.9 KB
results/diamonds/stage5/losses_base-random-omp-omp_without_weights-kmeans.png
0 → 100644
View file @
c43ae6c4
65.9 KB
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment