Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
[pre-commit.ci] pre-commit suggestions (#41)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit suggestions
* deprecated KMeans args
* pre-commit: no further update
* Apply suggestions from code review

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jirka <jirka.borovec@seznam.cz>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
  • Loading branch information
3 people committed Oct 12, 2021
1 parent aa8b548 commit 7463cfc
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Expand Up @@ -4,7 +4,7 @@ default_language_version:
ci:
autofix_prs: true
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
autoupdate_schedule: quarterly
# autoupdate_schedule: quarterly
# submodules: true

repos:
Expand All @@ -23,7 +23,7 @@ repos:
# name: fixing PEP8

- repo: https://github.com/PyCQA/isort
rev: 5.9.1
rev: 5.9.3
hooks:
- id: isort
name: imports
Expand All @@ -38,7 +38,7 @@ repos:
require_serial: false

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.7
rev: 0.7.10
hooks:
- id: mdformat
additional_dependencies:
Expand Down
2 changes: 1 addition & 1 deletion imsegm/classification.py
Expand Up @@ -1127,7 +1127,7 @@ def down_sample_dict_features_kmean(dict_features, nb_samples):
if len(features) <= nb_samples:
dict_features_new[label] = features.copy()
continue
kmeans = cluster.KMeans(n_clusters=nb_samples, init='random', n_init=3, max_iter=5, n_jobs=-1)
kmeans = cluster.KMeans(n_clusters=nb_samples, init='random', n_init=3, max_iter=5)
dist = kmeans.fit_transform(features)
find_min = np.argmin(dist, axis=0)
dict_features_new[label] = features[find_min, :]
Expand Down
10 changes: 5 additions & 5 deletions imsegm/graph_cuts.py
Expand Up @@ -127,7 +127,7 @@ def estim_class_model(features, nb_classes, estim_model='GMM', pca_coef=None, us
if init_type == 'kmeans':
mm.set_params(n_init=1)
# http://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html
kmeans = cluster.KMeans(n_clusters=nb_classes, init='k-means++', n_jobs=-1)
kmeans = cluster.KMeans(n_clusters=nb_classes, init='k-means++')
y = kmeans.fit_predict(features)
elif init_type == 'Otsu':
mm.set_params(n_init=1)
Expand Down Expand Up @@ -209,7 +209,7 @@ def compute_multivarian_otsu(features):
# mm = mixture.GMM(n_components=nb_classes, covariance_type='full', n_iter=999)
# if init == 'kmeans':
# # http://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html
# kmeans = cluster.KMeans(n_clusters=nb_classes, init='k-means++', n_jobs=-1)
# kmeans = cluster.KMeans(n_clusters=nb_classes, init='k-means++')
# y = kmeans.fit_predict(features)
# mm.fit(features, y)
# else:
Expand Down Expand Up @@ -240,7 +240,7 @@ def estim_class_model_gmm(features, nb_classes, init='kmeans'):
gmm = mixture.GaussianMixture(n_components=nb_classes, covariance_type='full', max_iter=99)
if init == 'kmeans':
# http://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html
kmeans = cluster.KMeans(n_clusters=nb_classes, init='k-means++', n_jobs=-1)
kmeans = cluster.KMeans(n_clusters=nb_classes, init='k-means++')
y = kmeans.fit_predict(features)
gmm.fit(features, y)
else:
Expand Down Expand Up @@ -275,10 +275,10 @@ def estim_class_model_kmeans(features, nb_classes, init_type='k-means++', max_it
if init_type == 'quantiles':
quntiles = np.linspace(5, 95, nb_classes).tolist()
init_perc = np.array(np.percentile(features, quntiles, axis=0))
kmeans = cluster.KMeans(nb_classes, init=init_perc, max_iter=2, n_jobs=-1)
kmeans = cluster.KMeans(nb_classes, init=init_perc, max_iter=2)
else:
nb_inits = max(1, int(np.sqrt(max_iter)))
kmeans = cluster.KMeans(nb_classes, init=init_type, max_iter=max_iter, n_init=nb_inits, n_jobs=-1)
kmeans = cluster.KMeans(nb_classes, init=init_type, max_iter=max_iter, n_init=nb_inits)
y = kmeans.fit_predict(features)
gmm = mixture.GaussianMixture(n_components=nb_classes, covariance_type='full', max_iter=1)
gmm.fit(features, y)
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Expand Up @@ -3,9 +3,9 @@ Cython >= 0.28 # 0.27 fails with python 3.7
numpy >= 1.15.0 # version 1.16 breaks skimage 0.14
scipy >= 1.2.0
pandas >= 0.23.0
Pillow>=8.1.2
Pillow >= 8.1.2
matplotlib >= 3.0.0
scikit-learn >= 0.19.0
scikit-learn >= 0.19.0, !=1.0 # fails with segmentation fault on MacOS
scikit-image >= 0.14.0
tqdm >= 4.7.4
olefile == 0.44 # new version - ImportError: No module named OleFileIO_PL
Expand Down
2 changes: 1 addition & 1 deletion tests/requirements.txt
@@ -1,4 +1,3 @@
nose>=1.3.7
coverage
codecov
pytest>4.0
Expand All @@ -8,3 +7,4 @@ codacy-coverage
check-manifest
flake8>3.0
yapf
isort

0 comments on commit 7463cfc

Please sign in to comment.