File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,24 @@ class ChangedBehaviorWarning(UserWarning):
4848class  ConvergenceWarning (UserWarning ):
4949    """Custom warning to capture convergence problems 
5050
51+     Examples 
52+     -------- 
53+ 
54+     >>> import numpy as np 
55+     >>> import warnings 
56+     >>> from sklearn.cluster import KMeans 
57+     >>> from sklearn.exceptions import ConvergenceWarning 
58+     >>> warnings.simplefilter("always", ConvergenceWarning) 
59+     >>> X = np.asarray([[0, 0], 
60+     ...                 [0, 1], 
61+     ...                 [1, 0], 
62+     ...                 [1, 0]])  # last point is duplicated 
63+     >>> with warnings.catch_warnings(record=True) as w: 
64+     ...    km = KMeans(n_clusters=4).fit(X) 
65+     ...    print(w[-1].message) 
66+     Number of distinct clusters (3) found smaller than n_clusters (4). 
67+     Possibly due to duplicate points in X. 
68+ 
5169    .. versionchanged:: 0.18 
5270       Moved from sklearn.utils. 
5371    """ 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments