-
Notifications
You must be signed in to change notification settings - Fork 95
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
refactor: Add Modeler classes for Oracles #137
Conversation
nhanitvn
commented
Mar 4, 2022
•
edited
Loading
edited
- Add Modeler classes
- Refactor code to build/train Oracles
- Use H1st Predictive Model for ensembling Students and Teacher's output instead of the general H1st StackEnsemble
- Test cases passed
self.stats = {} | ||
|
||
def generate_features(self, data: Dict): | ||
@classmethod |
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.
@nhanitvn Did you use @classmethod here because you need to use this method in OracleModeler without instantiating Oracle class ? I am not sure if this is the best option. Have you thought about using @staticmethod ?
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 know any benefit of using @classmethod if it is not factory method.
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.
The benefit is that you can override generate_features()
in Oracle's subclasses and have the overridden one called instead :)
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 got it.
@@ -127,25 +119,22 @@ def predict(self, input_data: Dict) -> Dict: | |||
raise RuntimeError('No student built') | |||
|
|||
# Generate features to get students' predictions | |||
predict_data = self.generate_data(input_data) | |||
predict_data = self.__class__.generate_data(input_data, self.teacher, self.stats) |
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.
If we make generate_data a staticmethod, then this will look more beautiful.
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.
This looks ugly here. However, the classmethod benefit the build_model(). Check TimeseriesOracleModeler and you see that we don't need to re-implement build_model(). With static method, you cannot do so.
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 got it