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

Classifier #1353

Merged
merged 12 commits into from
Jun 6, 2024
Merged

Classifier #1353

merged 12 commits into from
Jun 6, 2024

Conversation

matakleo
Copy link
Contributor

@matakleo matakleo commented Jun 3, 2024

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

  • Link to any issues that the PR addresses
  • Add labels
  • Open as a draft PR
    until ready for review
  • Make sure GitHub tests pass
  • Mark PR as "Ready for Review"

@matakleo matakleo added the enhancement New feature or request label Jun 3, 2024
@CLAassistant
Copy link

CLAassistant commented Jun 3, 2024

CLA assistant check
All committers have signed the CLA.

@@ -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()) {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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

Copy link
Contributor Author

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) {
Copy link
Contributor Author

@matakleo matakleo Jun 6, 2024

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">
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@matakleo matakleo marked this pull request as ready for review June 6, 2024 17:39
@matakleo matakleo requested a review from haileyajohnson as a code owner June 6, 2024 17:39
<attribute name="classify"/>
<values>1.0 -2.0 0.0 4.0 -5.0</values>
</variable>

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: formatting

@haileyajohnson haileyajohnson merged commit 5cc4025 into Unidata:maint-5.x Jun 6, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants