-
Notifications
You must be signed in to change notification settings - Fork 71
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
Classifier #1353
Classifier #1353
Conversation
@@ -939,6 +943,10 @@ private void createEnhancements() { | |||
if (normalizerAtt != null && this.enhanceMode.contains(Enhance.ApplyNormalizer) && dataType.isFloatingPoint()) { | |||
this.normalizer = Normalizer.createFromVariable(this); | |||
} | |||
Attribute classifierAtt = findAttribute(CDM.CLASSIFY); | |||
if (classifierAtt != null && this.enhanceMode.contains(Enhance.ApplyClassifier) && dataType.isFloatingPoint()) { |
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.
check if numeric instead of if floating point (isNumeric)
} | ||
} | ||
|
||
public static Classifier createFromArray(Array arr, DataType type) { |
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 can be deleted
/** wEmpty in case data not good */ | ||
public Classifier() {} | ||
|
||
private Classifier(Array arr, DataType type) { |
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 just one constructor is enough
} | ||
|
||
/** Classify double array */ | ||
public int[] classifyDoubleArray(Array arr) { |
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.
keep only the double method, the int and float are not really used
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.
instead of the if clauses, call your one-val method change
} | ||
|
||
/** for a single float */ | ||
public int classifyArray(float val) { |
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.
keep also only double
<values>1.0 -2.0 0.0 4.0 -5.0</values> | ||
</variable> | ||
|
||
<variable name="intPositives" shape="5" type="int"> |
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.
do the other two tests for ints as well
} | ||
|
||
/** enhance is not applied to Integers, so we expect the same values after application */ | ||
@Test |
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.
add some more test here
56727d0
to
1ed0023
Compare
<attribute name="classify"/> | ||
<values>1.0 -2.0 0.0 4.0 -5.0</values> | ||
</variable> | ||
|
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.
nit: formatting
Description of Changes
Added a Classifier class into filters. It serves as a classifier which assigns 0 to negative numbers and 1 to positives and zero. [e.g. x>=0 --> 1 | x<0 --> 0]
PR Checklist
until ready for review