-
Notifications
You must be signed in to change notification settings - Fork 165
Add MLEngine interface #33
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
Conversation
* | ||
*/ | ||
|
||
package org.opensearch.ml.engine; |
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.
Curiously, should the ML engine under the ml-algorithms project? Probably it's better to put the algorithms under the ML engine?
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.
Yeah, I got your point. Actually This MLEngine class is a public interface of all ml algorithms, so I put it in ml-algorithms project.
ml-algorithms/src/main/java/org/opensearch/ml/engine/MLEngine.java
Outdated
Show resolved
Hide resolved
ml-algorithms/src/main/java/org/opensearch/ml/engine/MLEngine.java
Outdated
Show resolved
Hide resolved
ml-algorithms/src/main/java/org/opensearch/ml/engine/contants/MLAlgoNames.java
Show resolved
Hide resolved
ml-algorithms/src/main/java/org/opensearch/ml/engine/regression/LinearRegression.java
Show resolved
Hide resolved
ml-algorithms/src/test/java/org/opensearch/ml/engine/helper/KMeansHelper.java
Show resolved
Hide resolved
ml-algorithms/src/test/java/org/opensearch/ml/engine/helper/LinearRegressionHelper.java
Show resolved
Hide resolved
if (parameters == null) { | ||
parameters = new ArrayList<>(); | ||
} | ||
switch (algoName.toLowerCase()) { |
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.
Probably we need to validate the parameters here? for example, if the algoName is null, then we will get a NullPointerException.
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 am not so sure about it. I think throwing a NullPointerException is OK, isn't it?
ml-algorithms/src/main/java/org/opensearch/ml/engine/clustering/KMeans.java
Show resolved
Hide resolved
Model model = trainKMeansModel(); | ||
Assert.assertEquals("KMeans", model.getName()); | ||
Assert.assertEquals(1, model.getVersion()); | ||
Assert.assertNotNull(model.getContent()); |
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.
Could we verify the model is the expected one instead of only verify it's not null?
ml-algorithms/src/test/java/org/opensearch/ml/engine/MLEngineTest.java
Outdated
Show resolved
Hide resolved
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.
to get the high level picture, we need have a sync-up first about this engine and algorithm interfaces.
basically I think only train and prediction interfaces aren't enough to support all use cases
switch (algoName.toLowerCase()) { | ||
case MLAlgoNames.KMEANS: | ||
KMeans kMeans = new KMeans(parameters); | ||
return kMeans.train(dataFrame); |
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.
how to handle the case when the train isn't supported by some algorithms?
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.
enter default branch and throw exception
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.
Approved, thanks for all the changes!
* add MLEngine interface
Description
Add MLEngine interface
Issues Resolved
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.