-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Make Random Forest observable. #4655
[WIP] Make Random Forest observable. #4655
Conversation
fe8419a
to
9068b55
Compare
tests/unit/labels/MockLabels.h
Outdated
@@ -12,6 +12,14 @@ namespace shogun { | |||
MOCK_METHOD0(get_values, SGVector<float64_t>()); | |||
|
|||
virtual const char* get_name() const { return "MockCLabels"; } | |||
|
|||
protected: | |||
virtual CSGObject *create_empty() const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont understand why you need this as there is never an empty instance created ... or am I wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were situations in which we were emitting MockLabels
from a machine and therefore I needed to implement the create_empty()
method to make clone()
work.
d21f741
to
bac22e6
Compare
9068b55
to
cecc5df
Compare
64e3ab7
to
fdf4aa0
Compare
* Round of clang format.
fdf4aa0
to
7320afe
Compare
* Round of clang format; * Remove CombinationRule casting inside BagginMachine unit tests.
7320afe
to
17d9464
Compare
* Round of clang format; * Remove CombinationRule casting inside BagginMachine unit tests.
7eea42f
to
e9113af
Compare
* Round of clang format; * Remove CombinationRule casting inside BagginMachine unit tests.
e9113af
to
18fcded
Compare
2b7b795
to
b8cf6e0
Compare
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'm picking it up again these days. Let's see after I fix all these merge conflicts. |
* Round of clang format; * Remove CombinationRule casting inside BagginMachine unit tests.
18fcded
to
9a4ed4b
Compare
* Fix CBaggingMachine unit tests by using the put()/get() methods; * Fix RandomForest constructors (remove missing methods); * Fix RandomForest unit tests;
It can be called now without passing an explicit CEvaluation object. This will be generated automatically, given the features' type, and it will be used to compute the oob error.
It will emit oob error during training and each of the trained machines.
* Add CCombinationRule to base_types.h; * Add missing SG_REF()/SG_UNREF() pair.
These are added to enable put() semantic. * Fix random forest meta examples;
* Round of clang format; * Remove CombinationRule casting inside BagginMachine unit tests.
* Removed some observable code until the get_oob_error() gets fixed (or updated);
* observe() now accept a const reference to the ObservedValue; * BaggingMachine should be better observable;
9a4ed4b
to
da1aa6d
Compare
* Fix RandomForest unit test (casting error); * Remove compute_oob observable; * Remove Random Forest meta example (they were probably left there when rebasing against develop); * Fix code style;
The OOB error is computed only if the combination rule and the evaluation metric are specified. Moreover, there must be observers attached to the machine.
6eb4e3a
to
9dfa8e4
Compare
if (this->m_combination_rule && this->m_oob_evaluation_metric && | ||
this->get_num_subscriptions() != 0) | ||
{ | ||
auto oob_error = this->get_oob_error(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: you now always compute the oob error whenever there is an observer ...Is that good? I forgot how the specifying to be observed variables works, but can't the user somehow pick what she wants to observe? In that case this should only be computed if the user requested it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the idea is that as long as the model has some observer attached, then it will output all the available observations. This means that the OOB error will be computed regardless of the user preferences.
It will be the observer job to filter the observations and keep just the ones that the user wants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment, there is no way to tell an observable model to emit only certain observations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think that’s good and we should probably think about a way to avoid this. Passing (and ignoring) pointers to existing data is one thing, but expensive operations should only be executed if desired.
I could imagine that this could be done with a lambda function that is only executed if the observer actually wants (as in user instructed) to store the data. Maybe @gf712 has an idea he is the lambda master?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the problem. One small issue here is that the model does not have any idea about which things the observers want to observe. I guess the solution could be emitting functions (lambdas) instead which can then be executed by the observers if they want to store that kind of data. Is this what you meant @karlnapf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the model doesnt know. In general, it should offer the observer to observe something (which the observer then can or cannot do, depending on its settings). Passing a pointer is a good example for that. The observer can clone the underlying structure for example.
But for costly things, passing a lambda that would compute something expensive is a better choice imo, so yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, that makes sense! I will do some experimenting to try adding this lambda feature. I'm leaving this one as it is (or maybe we could merge it in a feature
branch) and then I will open a new PR with the lambda observers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I say let's just keep this PR open, and then you could rebase it once the the lambda thing works. Alternatively, just remove the oob error stuff and we can merge everything else?
…ions. * Fix test style;
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue is now being closed due to a lack of activity. Feel free to reopen it. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue is now being closed due to a lack of activity. Feel free to reopen it. |
No description provided.