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
8b3a6c49
Commit
8b3a6c49
authored
5 years ago
by
Charly LAMOTHE
Browse files
Options
Downloads
Patches
Plain Diff
Use OMP to compute the prediction instead of doing it manually (same results)
parent
0fce0319
No related branches found
No related tags found
1 merge request
!3
clean scripts
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/bolsonaro/models/omp_forest_regressor.py
+5
-7
5 additions, 7 deletions
code/bolsonaro/models/omp_forest_regressor.py
with
5 additions
and
7 deletions
code/bolsonaro/models/omp_forest_regressor.py
+
5
−
7
View file @
8b3a6c49
...
...
@@ -38,7 +38,8 @@ class OmpForestRegressor(BaseEstimator):
def
fit
(
self
,
X_forest
,
y_forest
,
X_omp
,
y_omp
):
self
.
_forest
=
self
.
_train_forest
(
X_forest
,
y_forest
)
self
.
_weights
=
self
.
_extract_subforest
(
X_omp
,
y_omp
)
self
.
_omp
=
self
.
_extract_subforest
(
X_omp
,
y_omp
)
self
.
_weights
=
self
.
_omp
.
coef_
return
self
def
score_regressor
(
self
,
X
,
y
):
...
...
@@ -56,8 +57,8 @@ class OmpForestRegressor(BaseEstimator):
if
self
.
_models_parameters
.
normalize_D
:
D
/=
self
.
_forest_norms
# TODO: use self._models_parameters.normalize_weights here
predictions
=
D
@
self
.
_
weights
# TODO: use self._models_parameters.normalize_weights here
?
predictions
=
self
.
_
omp
.
predict
(
D
)
return
predictions
...
...
@@ -109,10 +110,7 @@ class OmpForestRegressor(BaseEstimator):
fit_intercept
=
False
,
normalize
=
False
)
self
.
_logger
.
debug
(
"
Apply orthogonal maching pursuit on forest for {} extracted trees.
"
.
format
(
self
.
_models_parameters
.
extracted_forest_size
))
omp
.
fit
(
D
,
y
)
weights
=
omp
.
coef_
# question: why not to use directly the omp estimator instead of bypassing it using the coefs?
return
weights
return
omp
.
fit
(
D
,
y
)
def
_forest_prediction
(
self
,
X
):
return
np
.
array
([
tree
.
predict
(
X
)
for
tree
in
self
.
_forest
]).
T
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