@@ -654,18 +654,13 @@ class TSNE(BaseEstimator):
654
654
655
655
.. versionadded:: 0.22
656
656
657
- square_distances : True or 'legacy', default='legacy'
658
- Whether TSNE should square the distance values. ``'legacy'`` means
659
- that distance values are squared only when ``metric="euclidean"``.
660
- ``True`` means that distance values are squared for all metrics.
657
+ square_distances : True, default='deprecated'
658
+ This parameter has no effect since distance values are always squared
659
+ since 1.1.
661
660
662
- .. versionadded:: 0.24
663
- Added to provide backward compatibility during deprecation of
664
- legacy squaring behavior.
665
- .. deprecated:: 0.24
666
- Legacy squaring behavior was deprecated in 0.24. The ``'legacy'``
667
- value will be removed in 1.1 (renaming of 0.26), at which point the
668
- default value will change to ``True``.
661
+ .. deprecated:: 1.1
662
+ `square_distances` has no effect from 1.1 and will be removed in
663
+ 1.3.
669
664
670
665
Attributes
671
666
----------
@@ -755,7 +750,7 @@ def __init__(
755
750
method = "barnes_hut" ,
756
751
angle = 0.5 ,
757
752
n_jobs = None ,
758
- square_distances = "legacy " ,
753
+ square_distances = "deprecated " ,
759
754
):
760
755
self .n_components = n_components
761
756
self .perplexity = perplexity
@@ -771,7 +766,6 @@ def __init__(
771
766
self .method = method
772
767
self .angle = angle
773
768
self .n_jobs
10000
= n_jobs
774
- # TODO Revisit deprecation of square_distances for 1.1-1.3 (#12401)
775
769
self .square_distances = square_distances
776
770
777
771
def _fit (self , X , skip_num_points = 0 ):
@@ -808,26 +802,19 @@ def _fit(self, X, skip_num_points=0):
808
802
raise ValueError ("'method' must be 'barnes_hut' or 'exact'" )
809
803
if self .angle < 0.0 or self .angle > 1.0 :
810
804
raise ValueError ("'angle' must be between 0.0 - 1.0" )
811
- if self .square_distances not in [True , "legacy" ]:
812
- raise ValueError ("'square_distances' must be True or 'legacy'." )
805
+ if self .square_distances != "deprecated" :
806
+ warnings .warn (
807
+ "The parameter `square_distances` has not effect and will be "
808
+ "removed in version 1.3." ,
809
+ FutureWarning ,
810
+ )
813
811
if self ._learning_rate == "auto" :
814
812
# See issue #18018
815
813
self ._learning_rate = X .shape [0 ] / self .early_exaggeration / 4
816
814
self ._learning_rate = np .maximum (self ._learning_rate , 50 )
817
815
else :
818
816
if not (self ._learning_rate > 0 ):
819
817
raise ValueError ("'learning_rate' must be a positive number or 'auto'." )
820
- if self .metric != "euclidean" and self .square_distances is not True :
821
- warnings .warn (
822
- "'square_distances' has been introduced in 0.24 to help phase "
823
- "out legacy squaring behavior. The 'legacy' setting will be "
824
- "removed in 1.1 (renaming of 0.26), and the default setting "
825
- "will be changed to True. In 1.3, 'square_distances' will be "
826
- "removed altogether, and distances will be squared by "
827
- "default. Set 'square_distances'=True to silence this "
828
- "warning." ,
829
- FutureWarning ,
830
- )
831
818
if self .method == "barnes_hut" :
832
819
X = self ._validate_data (
833
820
X ,
@@ -907,7 +894,7 @@ def _fit(self, X, skip_num_points=0):
907
894
"All distances should be positive, the metric given is not correct"
908
895
)
909
896
910
- if self .metric != "euclidean" and self . square_distances is True :
897
+ if self .metric != "euclidean" :
911
898
distances **= 2
912
899
913
900
# compute the joint probability distribution for the input space
@@ -958,13 +945,12 @@ def _fit(self, X, skip_num_points=0):
958
945
# Free the memory used by the ball_tree
959
946
del knn
960
947
961
- if self .square_distances is True or self .metric == "euclidean" :
962
- # knn return the euclidean distance but we need it squared
963
- # to be consistent with the 'exact' method. Note that the
964
- # the method was derived using the euclidean method as in the
965
- # input space. Not sure of the implication of using a different
966
- # metric.
967
- distances_nn .data **= 2
948
+ # knn return the euclidean distance but we need it squared
949
+ # to be consistent with the 'exact' method. Note that the
950
+ # the method was derived using the euclidean method as in the
951
+ # input space. Not sure of the implication of using a different
952
+ # metric.
953
+ distances_nn .data **= 2
968
954
969
955
# compute the joint probability distribution for the input space
970
956
P = _joint_probabilities_nn (distances_nn , self .perplexity , self .verbose )
0 commit comments