PR addressing https://github.com/scikit-learn/scikit-learn/issues/5229#5316
PR addressing https://github.com/scikit-learn/scikit-learn/issues/5229#5316carrillo wants to merge 8 commits intoscikit-learn:masterfrom
Conversation
…in Nystroem 1. Generated a class variable: KERNEL_DEFAULT_PARAMS dictionary of kernel default parameters. 2. Modified __init__(): Set default values for kernel to Null 3. Modified _get_kernel_parameters(): if the self.kernel parameter is not callable, it checks if the kernel is contained in the dictionary. For each kernel parameter defined in the dictionary it assigns the default if None specified in __init__() or the one specified.
|
I think you can uncomment |
|
Dear Tom, thanks for you comments. |
|
You could reuse your dictionary (with default values) where the old one (without default values) was used (here). >>>"gamma" in frozenset(["gamma", "degree", "coef0"])
True
>>>"gamma" in {"gamma": None, "degree": 3, "coef0": 1}
True |
…ameters. Removed KERNEL_DEFAULT_PARAMS in kernel_approximation.py
|
Sorry for the delay. I just implemented the changes: I added the default kernel parameters to the dictionary in pairwise.py, removed the dictionary in kernel_approximation.py and import the one in pairwise.py. |
|
This looks good to me. |
|
Should the test address anything else then calling the Nystroem approximation without specifying the gamma parameter for the rbf and chi^2 kernel (this is where Travis was failing). |
|
I have the feeling that the non-regression test is already covered here. Lines 164 - 169 call the kernels with default parameters: # test that available kernels fit and transform
kernels_available = kernel_metrics()
for kern in kernels_available:
trans = Nystroem(n_components=2, kernel=kern, random_state=rnd)
X_transformed = trans.fit(X).transform(X)
assert_equal(X_transformed.shape, (X.shape[0], 2))This test failed, because it called the chi2 kernel with the default gamma value for the rbf kernel (gamma:None). Now the default gamma for chi2 (1.) is taken from the dictionary. Please let me know if I should add another test. Thanks, Fernando |
|
Not entirely the change I had in mind, and The fix I suggested was passing a dict of arguments in the |
|
[sorry for prolonged absence] |
if the kernel is contained in the dictionary. If so, it assigns the default parameters contained KERNEL_DEFAULT_PARAMS if not specified in__init_()