-
Notifications
You must be signed in to change notification settings - Fork 20
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
fixed rbf kernel in cka #175
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #175 +/- ##
==========================================
+ Coverage 76.40% 76.42% +0.02%
==========================================
Files 40 40
Lines 2051 2053 +2
Branches 261 261
==========================================
+ Hits 1567 1569 +2
Misses 400 400
Partials 84 84
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
LGTM
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.
Left one question otherwise LGTM
"""Use an rbf kernel for computing the gram matrix. Sigma defines the width.""" | ||
GX = X @ X.T | ||
KX = np.diag(GX) - GX + (np.diag(GX) - GX).T | ||
if sigma is None: | ||
if self.sigma is None: | ||
mdist = np.median(KX[KX != 0]) | ||
sigma = math.sqrt(mdist) |
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.
Question, if self.sigma=None, you compute it's value, but shall it be stored? Or shall we recompute it every time?
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 could store it but the caveat here is that sigma
depends on the input variable X
which changes as soon as we use the feature space Y
instead of X
. I am not sure it's worth storing two sigmas, one for X
and one for Y
, if self.sigma=None
. Also, self.sigma=None
should be seen as a special case. Ideally, one assigns self.sigma
a specific value which is then used for the bandwidth of the rbf kernel irrespective of the feature space.
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.
Ok, agree
fixed sigma arg in rbf kernel