diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6dcea06a8a..cd70c882f6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,13 +2,18 @@ CHANGELOG ========= +1.3.dev1 +======== + +* bug-fix: Estimators: Change max_iterations hyperparameter key for KMeans + 1.3.0 -======= +===== * feature: Add chainer 1.2.5 -======== +===== * bug-fix: Change module names to string type in __all__ * feature: Save training output files in local mode diff --git a/src/sagemaker/amazon/kmeans.py b/src/sagemaker/amazon/kmeans.py index b4657bce42..9c9b234254 100644 --- a/src/sagemaker/amazon/kmeans.py +++ b/src/sagemaker/amazon/kmeans.py @@ -28,7 +28,7 @@ class KMeans(AmazonAlgorithmEstimatorBase): k = hp('k', gt(1), 'An integer greater-than 1', int) init_method = hp('init_method', isin('random', 'kmeans++'), 'One of "random", "kmeans++"', str) - max_iterations = hp('local_lloyd_max_iterations', gt(0), 'An integer greater-than 0', int) + max_iterations = hp('local_lloyd_max_iter', gt(0), 'An integer greater-than 0', int) tol = hp('local_lloyd_tol', (ge(0), le(1)), 'An float in [0, 1]', float) num_trials = hp('local_lloyd_num_trials', gt(0), 'An integer greater-than 0', int) local_init_method = hp('local_lloyd_init_method', isin('random', 'kmeans++'), 'One of "random", "kmeans++"', str) diff --git a/tests/integ/test_kmeans.py b/tests/integ/test_kmeans.py index 15fd15d3d2..7faed145bb 100644 --- a/tests/integ/test_kmeans.py +++ b/tests/integ/test_kmeans.py @@ -41,7 +41,7 @@ def test_kmeans(sagemaker_session): k=10, sagemaker_session=sagemaker_session, base_job_name='test-kmeans') kmeans.init_method = 'random' - kmeans.max_iterators = 1 + kmeans.max_iterations = 1 kmeans.tol = 1 kmeans.num_trials = 1 kmeans.local_init_method = 'kmeans++' @@ -49,6 +49,19 @@ def test_kmeans(sagemaker_session): kmeans.epochs = 1 kmeans.center_factor = 1 + assert kmeans.hyperparameters() == dict( + init_method=kmeans.init_method, + local_lloyd_max_iter=str(kmeans.max_iterations), + local_lloyd_tol=str(kmeans.tol), + local_lloyd_num_trials=str(kmeans.num_trials), + local_lloyd_init_method=kmeans.local_init_method, + half_life_time_size=str(kmeans.half_life_time_size), + epochs=str(kmeans.epochs), + extra_center_factor=str(kmeans.center_factor), + k=str(kmeans.k), + force_dense='True', + ) + kmeans.fit(kmeans.record_set(train_set[0][:100])) endpoint_name = name_from_base('kmeans') @@ -80,7 +93,7 @@ def test_async_kmeans(sagemaker_session): k=10, sagemaker_session=sagemaker_session, base_job_name='test-kmeans') kmeans.init_method = 'random' - kmeans.max_iterators = 1 + kmeans.max_iterations = 1 kmeans.tol = 1 kmeans.num_trials = 1 kmeans.local_init_method = 'kmeans++' @@ -88,6 +101,19 @@ def test_async_kmeans(sagemaker_session): kmeans.epochs = 1 kmeans.center_factor = 1 + assert kmeans.hyperparameters() == dict( + init_method=kmeans.init_method, + local_lloyd_max_iter=str(kmeans.max_iterations), + local_lloyd_tol=str(kmeans.tol), + local_lloyd_num_trials=str(kmeans.num_trials), + local_lloyd_init_method=kmeans.local_init_method, + half_life_time_size=str(kmeans.half_life_time_size), + epochs=str(kmeans.epochs), + extra_center_factor=str(kmeans.center_factor), + k=str(kmeans.k), + force_dense='True', + ) + kmeans.fit(kmeans.record_set(train_set[0][:100]), wait=False) training_job_name = kmeans.latest_training_job.name diff --git a/tests/unit/test_kmeans.py b/tests/unit/test_kmeans.py index f2ca262c3c..d6019e168a 100644 --- a/tests/unit/test_kmeans.py +++ b/tests/unit/test_kmeans.py @@ -74,7 +74,7 @@ def test_all_hyperparameters(sagemaker_session): assert kmeans.hyperparameters() == dict( k=str(ALL_REQ_ARGS['k']), init_method='random', - local_lloyd_max_iterations='3', + local_lloyd_max_iter='3', local_lloyd_tol='0.5', local_lloyd_num_trials='5', local_lloyd_init_method='kmeans++', @@ -82,7 +82,7 @@ def test_all_hyperparameters(sagemaker_session): epochs='10', extra_center_factor='2', eval_metrics='[\'msd\', \'ssd\']', - force_dense='True' + force_dense='True', )