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
369a053a
Commit
369a053a
authored
5 years ago
by
Luc Giffon
Browse files
Options
Downloads
Patches
Plain Diff
solve bug solution too fast
parent
dcbb16f2
No related branches found
No related tags found
1 merge request
!24
Resolve "non negative omp"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
code/bolsonaro/models/nn_omp.py
+8
-0
8 additions, 0 deletions
code/bolsonaro/models/nn_omp.py
code/bolsonaro/models/nn_omp_forest_regressor.py
+1
-0
1 addition, 0 deletions
code/bolsonaro/models/nn_omp_forest_regressor.py
with
9 additions
and
0 deletions
code/bolsonaro/models/nn_omp.py
+
8
−
0
View file @
369a053a
...
...
@@ -72,6 +72,9 @@ class NonNegativeOrthogonalMatchingPursuit:
tmp_T
=
T
[:,
bool_arr_selected_indexes
]
sol
=
nnls
(
tmp_T
,
y
)[
0
]
# non negative least square
residual
=
y
-
tmp_T
@
sol
int_used_atoms
=
np
.
sum
(
sol
.
astype
(
bool
))
if
int_used_atoms
!=
i
+
1
:
self
.
_logger
.
warning
(
"
Atom found but not used. {} < {}
"
.
format
(
int_used_atoms
,
i
+
1
))
if
i
+
1
==
next_solution
:
final_vec
=
np
.
zeros
(
T
.
shape
[
1
])
...
...
@@ -81,6 +84,11 @@ class NonNegativeOrthogonalMatchingPursuit:
i
+=
1
if
len
(
lst_intermediate_solutions
)
==
0
and
np
.
isclose
(
np
.
linalg
.
norm
(
residual
),
0
):
final_vec
=
np
.
zeros
(
T
.
shape
[
1
])
final_vec
[
bool_arr_selected_indexes
]
=
sol
# solution is full of zero but on selected indices
lst_intermediate_solutions
.
append
(
final_vec
)
nb_missing_solutions
=
len
(
self
.
requested_intermediate_solutions_sizes
)
-
len
(
lst_intermediate_solutions
)
if
nb_missing_solutions
>
0
:
...
...
This diff is collapsed.
Click to expand it.
code/bolsonaro/models/nn_omp_forest_regressor.py
+
1
−
0
View file @
369a053a
...
...
@@ -115,6 +115,7 @@ if __name__ == "__main__":
print
(
"
Score full forest on test
"
,
nn_ompforest
.
score_base_estimator
(
X_test
,
y_test
))
print
(
"
Size full forest
"
,
nnmodel_params
.
hyperparameters
[
"
n_estimators
"
])
print
(
"
Size extracted forests
"
,
intermediate_solutions
)
print
(
"
Actual size extracted forest
"
,
[
np
.
sum
(
coef
.
astype
(
bool
))
for
coef
in
nn_ompforest
.
_omp
.
get_coef
()])
print
(
"
Score non negative omp on train
"
,
nn_ompforest
.
score
(
X_train
,
y_train
))
print
(
"
Score non negative omp on test
"
,
nn_ompforest
.
score
(
X_test
,
y_test
))
print
(
"
Score omp on train
"
,
omp_forest
.
score
(
X_train
,
y_train
))
...
...
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