Skip to content
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

integrate tribuo anomaly detection based on libSVM #96

Merged
merged 3 commits into from
Feb 5, 2022

Conversation

ylwu-amzn
Copy link
Collaborator

@ylwu-amzn ylwu-amzn commented Dec 2, 2021

Signed-off-by: Yaliang Wu ylwu@amazon.com

Description

Integrate tribuo anomaly detection algorithm which based on libSVM. Check this doc https://tribuo.org/learn/4.1/docs/features.html#anomaly-detection

Issues Resolved

#98

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

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.

@ylwu-amzn ylwu-amzn requested a review from a team December 2, 2021 19:05
@ylwu-amzn ylwu-amzn force-pushed the libsvm branch 2 times, most recently from c102aa4 to 064e441 Compare December 2, 2021 19:16
@ylwu-amzn ylwu-amzn force-pushed the libsvm branch 2 times, most recently from 477bc0e to 69594a7 Compare December 2, 2021 21:55
@ylwu-amzn ylwu-amzn removed the request for review from wnbts February 3, 2022 08:10
@ylwu-amzn ylwu-amzn requested a review from Zhangxunmt February 3, 2022 22:41
Zhangxunmt
Zhangxunmt previously approved these changes Feb 4, 2022
Copy link
Collaborator

@Zhangxunmt Zhangxunmt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved with 2 comments.

}

@Override
public int getVersion() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious: this version is always 1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We set version as 1 for first release. May change to higher version in future

Comment on lines +96 to +117
KernelType kernelType = parseKernelType();
SVMParameters params = new SVMParameters<>(new SVMAnomalyType(SVMAnomalyType.SVMMode.ONE_CLASS), kernelType);
Double gamma = Optional.ofNullable(parameters.getGamma()).orElse(DEFAULT_GAMMA);
Double nu = Optional.ofNullable(parameters.getNu()).orElse(DEFAULT_NU);
params.setGamma(gamma);
params.setNu(nu);
if (parameters.getCost() != null) {
params.setCost(parameters.getCost());
}
if (parameters.getCoeff() != null) {
params.setCoeff(parameters.getCoeff());
}
if (parameters.getEpsilon() != null) {
params.setEpsilon(parameters.getEpsilon());
}
if (parameters.getDegree() != null) {
params.setDegree(parameters.getDegree());
}
MutableDataset<Event> data = TribuoUtil.generateDataset(dataFrame, new AnomalyFactory(),
"Anomaly detection LibSVM training data from OpenSearch", TribuoOutputType.ANOMALY_DETECTION_LIBSVM);

LibSVMAnomalyTrainer trainer = new LibSVMAnomalyTrainer(params);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: why not use a function to instantiate the params and LibSVMAnomalyTrainer to make the train() body smaller?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will tune this part in next PR.

Signed-off-by: Yaliang Wu <ylwu@amazon.com>
Signed-off-by: Yaliang Wu <ylwu@amazon.com>
Signed-off-by: Yaliang Wu <ylwu@amazon.com>
@ylwu-amzn ylwu-amzn merged commit f8bdd30 into opensearch-project:main Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants