-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
IGNITE-13386 [ML]: Add new distances (BrayCurtis, Canberra, JensenShannon and etc) #8197
Conversation
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.
Functionality is good, need to add more comments to avoid problems with merging and TC
private final Double base; | ||
|
||
public JensenShannonDistance() { | ||
base = null; |
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 add here the default value which could make sense?
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 Math.E
as default value because Math.log(Math.E) == 1
and js /= Math.log(Math.E)
is equal to js /= 1
import org.apache.ignite.ml.math.util.MatrixUtil; | ||
|
||
/** | ||
* Calculates the JensenShannonDistance distance between two points. |
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 you please add a link to the Wiki or paper or put the formula in pseudocode (will be useful for understanding)?
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.
Added link to wikipedia.
import org.apache.ignite.ml.math.util.MatrixUtil; | ||
|
||
/** | ||
* Calculates the Canberra distance between two points. |
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 you please add a link to the Wiki or paper or put the formula in pseudocode (will be useful for understanding)?
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.
Added link to wikipedia.
import org.apache.ignite.ml.math.util.MatrixUtil; | ||
|
||
/** | ||
* Calculates the Bray Curtis distance between two points. |
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 you please add a link to the Wiki or paper or put the formula in pseudocode (will be useful for understanding)?
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.
Added link to wikipedia.
import static org.junit.Assert.assertEquals; | ||
|
||
@RunWith(Parameterized.class) | ||
public class BrayCurtisDistanceTest { |
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 a comment for this 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 comment like
/**
* Evaluate BrayCurtisDistance in multiple test datasets
*/
|
||
private final TestData testData; | ||
|
||
public CanberraDistanceTest(TestData testData) { |
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.
Please, comment this
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 comment like
/** */
new BrayCurtisDistance(), | ||
new CanberraDistance(), | ||
new JensenShannonDistance(), | ||
new WeightedMinkowskiDistance(4, new DenseVector(new double[]{1, 1, 1})), |
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.
Maybe these parameters could become default?
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.
We can set default value for p
(power) parameter as 2
, but weight
can not be default because weight's is dimensional dependent. If we want to evaluate distance between d(a,b)
, then a.size() == b.size() && a.size() == weight.size()
.
Or I can use null
for weight
and use them only when weight != null
.
import static org.junit.Assert.assertEquals; | ||
|
||
@RunWith(Parameterized.class) | ||
public class JensenShannonDistanceTest { |
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.
Comment this class please
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 comment like
/** */
import static org.junit.Assert.assertEquals; | ||
|
||
@RunWith(Parameterized.class) | ||
public class WeightedMinkowskiDistanceTest { |
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.
Comment this class please
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 comment like
/** */
} | ||
|
||
@Test | ||
public void 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.
change the test name to test+, because it could create problems with next migration to next versions of JUNIt framework
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 renamed my tests like test<distanceName
.
fde8a4b
to
7c86935
Compare
7c86935
to
b7d1583
Compare
add distances
Issue: https://issues.apache.org/jira/browse/IGNITE-13386