def _joint_probabilities_nn(distances, neighbors, desired_perplexity, verbose):
 distances = astype(distances, np.float32, copy=False)
 neighbors = astype(neighbors, np.int64, copy=False)
 conditional_P = _utils._binary_search_perplexity(distances, neighbors, desired_perplexity, verbose)
 m = 'All probabilities should be finite'
 assert np.all(np.isfinite(conditional_P)), m
 P = (conditional_P + conditional_P.T)
 sum_P = np.maximum(np.sum(P), MACHINE_EPSILON)
 P = np.maximum((squareform(P) / sum_P), MACHINE_EPSILON)
 assert np.all((np.abs(P) <= 1.0))
 return P

def _joint_probabilities_nn ( distances , neighbors , desired_perplexity , verbose ) : distances = astype ( distances , np . float32 , copy = False ) neighbors = astype ( neighbors , np . int64 , copy = False ) conditional_P = _utils . _binary_search_perplexity ( distances , neighbors , desired_perplexity , verbose ) m = 'All probabilities should be finite' assert np . all ( np . isfinite ( conditional_P ) ) , m P = ( conditional_P + conditional_P . T ) sum_P = np . maximum ( np . sum ( P ) , MACHINE_EPSILON ) P = np . maximum ( ( squareform ( P ) / sum_P ) , MACHINE_EPSILON ) assert np . all ( ( np . abs ( P ) <= 1.0 ) ) return P
compute joint probabilities p_ij from distances using just nearest neighbors .