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
af068a00
Commit
af068a00
authored
5 years ago
by
Léo Bouscarrat
Browse files
Options
Downloads
Patches
Plain Diff
Better to take non zero values of list as indicated in the numpy doc
parent
2d896dd1
No related branches found
No related tags found
2 merge requests
!20
Resolve "integration-sota"
,
!19
WIP: Resolve "Adding new datasets"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
code/bolsonaro/models/omp_forest.py
+2
-5
2 additions, 5 deletions
code/bolsonaro/models/omp_forest.py
code/bolsonaro/models/omp_forest_classifier.py
+1
-3
1 addition, 3 deletions
code/bolsonaro/models/omp_forest_classifier.py
with
3 additions
and
8 deletions
code/bolsonaro/models/omp_forest.py
+
2
−
5
View file @
af068a00
...
...
@@ -136,14 +136,11 @@ class SingleOmpForest(OmpForest):
:param X: a Forest
:return: a np.array of the predictions of the entire forest
"""
forest_predictions
=
self
.
_base_estimator
_predictions
(
X
).
T
forest_predictions
=
np
.
array
([
tree
.
predict
(
X
)
for
tree
in
self
.
_base_
forest_
estimator
.
estimators_
])
if
self
.
_models_parameters
.
normalize_D
:
forest_predictions
/=
self
.
_forest_norms
weights
=
self
.
_omp
.
coef_
omp_trees_indices
=
np
.
nonzero
(
weights
)[
0
]
select_trees
=
np
.
mean
(
forest_predictions
[
omp_trees_indices
],
axis
=
0
)
print
(
len
(
omp_trees_indices
))
select_trees
=
np
.
mean
(
forest_predictions
[
weights
!=
0
],
axis
=
0
)
return
select_trees
This diff is collapsed.
Click to expand it.
code/bolsonaro/models/omp_forest_classifier.py
+
1
−
3
View file @
af068a00
...
...
@@ -40,9 +40,7 @@ class OmpForestBinaryClassifier(SingleOmpForest):
forest_predictions
/=
self
.
_forest_norms
weights
=
self
.
_omp
.
coef_
omp_trees_indices
=
np
.
nonzero
(
weights
)
omp_trees_predictions
=
forest_predictions
[
omp_trees_indices
].
T
[
1
]
omp_trees_predictions
=
forest_predictions
[
weights
!=
0
].
T
[
1
]
# Here forest_pred is the probability of being class 1.
...
...
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