Skip to content

Implementing KMedoids in scikit-learn-extra #12

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

Merged
merged 26 commits into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cd19b57
Added kmedoids code
znd4 Apr 7, 2019
3e18444
changed k_medoids_ imports to absolute
znd4 Apr 23, 2019
936919d
Merge branch 'master' of https://github.com/scikit-learn-contrib/scik…
znd4 Apr 29, 2019
d4c086c
Added .vscode to .gitignore
znd4 Apr 29, 2019
bacc931
Add venv to .gitignore
znd4 Apr 29, 2019
0cb8e43
Added cluster tests
znd4 Apr 29, 2019
96f3a2e
Fix KMedoids docstring
znd4 Apr 29, 2019
8d9d9d6
Reconfigure _kpp_init tests
znd4 Apr 30, 2019
8e534e8
added documentation
znd4 May 11, 2019
4d61529
Rename k_medoids_.py -> _k_medoids.py
znd4 Jul 26, 2019
03f9e54
Update conf.py to include mathjax
znd4 Jul 26, 2019
2e95287
Add KMedoids to test_common.py
znd4 Jul 26, 2019
0e1ee5b
add plot_kmedoids_digits.py
znd4 Jul 26, 2019
ee1688b
Add Examples line to KMedoids docstring
znd4 Jul 26, 2019
e96e2b0
Remove duplicate examples section in _k_medoids.py docstring
znd4 Jul 26, 2019
07f6e3c
ACTUALLY remove duplicate examples section
znd4 Jul 26, 2019
9910804
Add sphinx gallery of plot_kmedoids_digits.py
znd4 Jul 26, 2019
0c8d032
Added k-medoids++ to help message
znd4 Jul 26, 2019
0368daa
Merge branch 'master' into kmedoids
znd4 Jul 26, 2019
3d71001
Run `black` on code
znd4 Jul 27, 2019
182d505
Remove commented out math code
znd4 Jul 27, 2019
88d9630
Remove unnecessary plot_kmedoids_digits.py
znd4 Jul 27, 2019
9405d98
Remove `x_squared_norms` from _kpp_init (copied over from kmeans)
znd4 Jul 27, 2019
0989f88
Add comment for _kpp_init
znd4 Jul 27, 2019
d76d6b8
update n_samples -> n_query, where appropriate
znd4 Jul 28, 2019
c060b0e
Add sklearn_extra/cluster/tests/__init__.py
rth Jul 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ __pycache__/
# C extensions
*.so

# Text Editors
.vscode/

# scikit-learn specific
doc/_build/
doc/auto_examples/
Expand All @@ -17,6 +20,7 @@ doc/datasets/generated/
# Distribution / packaging

.Python
venv/
env/
build/
develop-eggs/
Expand Down
23 changes: 12 additions & 11 deletions benchmarks/bench_rbfsampler_fastfood.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
Y /= Y.sum(axis=1)[:, np.newaxis]

# calculate feature maps
gamma = 10.
gamma = 10.0
sigma = np.sqrt(1 / (2 * gamma))
number_of_features_to_generate = 4096*4
number_of_features_to_generate = 4096 * 4

exact_start = datetime.datetime.utcnow()
# original rbf kernel method:
Expand All @@ -27,23 +27,24 @@
exact_spent_time = exact_end - exact_start
print("Timimg exact rbf: \t\t", exact_spent_time)

rbf_transform = Fastfood(sigma=sigma,
n_components=number_of_features_to_generate,
tradeoff_mem_accuracy='mem',
random_state=42)
rbf_transform = Fastfood(
sigma=sigma,
n_components=number_of_features_to_generate,
tradeoff_mem_accuracy="mem",
random_state=42,
)
_ = rbf_transform.fit(X)
fastfood_fast_vec_start = datetime.datetime.utcnow()
# Fastfood: approximate kernel mapping
_ = rbf_transform.transform(X)
_ = rbf_transform.transform(Y)
fastfood_fast_vec_end = datetime.datetime.utcnow()
fastfood_fast_vec_spent_time = fastfood_fast_vec_end - \
fastfood_fast_vec_start
fastfood_fast_vec_spent_time = fastfood_fast_vec_end - fastfood_fast_vec_start
print("Timimg fastfood fast vectorized: \t\t", fastfood_fast_vec_spent_time)

rks_rbf_transform = RBFSampler(gamma=gamma,
n_components=number_of_features_to_generate,
random_state=42)
rks_rbf_transform = RBFSampler(
gamma=gamma, n_components=number_of_features_to_generate, random_state=42
)
_ = rks_rbf_transform.fit(X)
rks_start = datetime.datetime.utcnow()
# Random Kitchens Sinks: approximate kernel mapping
Expand Down
10 changes: 10 additions & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,13 @@ Kernel approximation
:template: class.rst

kernel_approximation.Fastfood

Clustering
====================

.. autosummary::
:toctree: generated/
:template: class.rst

cluster.KMedoids

Loading