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

Fast Kernel Classifier not always fast #34

Open
amueller opened this issue Aug 12, 2019 · 2 comments
Open

Fast Kernel Classifier not always fast #34

amueller opened this issue Aug 12, 2019 · 2 comments

Comments

@amueller
Copy link
Member

amueller commented Aug 12, 2019

I'm looking at the electricity dataset https://www.openml.org/d/151
as a benchmark for Fast Kernel Classifier.
X.shape = (45312, 8) which I feel should be a good candidate for this model to be fast.

However, SVC is about 10% or 20% faster.

from sklearn.datasets import fetch_openml
from sklearn.svm import SVC
from sklearn.model_selection import cross_validate
import pandas as pd
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import make_pipeline
import numpy as np

data = fetch_openml(data_id = 151)
X = pd.DataFrame(data.data)
y = pd.Series(data.target)

svc = SVC(kernel = 'rbf', gamma='scale',
          random_state= 1)

svc_cv = cross_validate(make_pipeline(StandardScaler(), svc), X, y, cv = 10)

print('Fit time \t', np.mean(svc_cv['fit_time']))
print('Score \t\t', np.mean(svc_cv['test_score']))

from sklearn_extra.kernel_methods import EigenProClassifier as FKCEigenPro


epc = FKCEigenPro(kernel = 'rbf', gamma='scale',
          random_state= 1)

epc_cv = cross_validate(make_pipeline(StandardScaler(), epc), X, y, cv = 10)
print('Fit time \t', np.mean(epc_cv['fit_time']))
print('Score \t\t', np.mean(epc_cv['test_score']))

Any idea what's going on here? The time is basically exclusively spent in the _kernel method.

cc @Alex7Li

@amueller
Copy link
Member Author

gamma = scale is ignored, see #35

@amueller
Copy link
Member Author

amueller commented Aug 12, 2019

Running the same script with this dataset:
https://www.openml.org/d/4534 "PhishingWebsites" is even a bigger difference, it seems; FKC takes 10 seconds, SVC takes 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant