本文整理匯總了Python中sklearn.neighbors.BallTree方法的典型用法代碼示例。如果您正苦於以下問題:Python neighbors.BallTree方法的具體用法?Python neighbors.BallTree怎麽用?Python neighbors.BallTree使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在模塊sklearn.neighbors的用法示例。
在下文中一共展示了neighbors.BallTree方法的19個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Python代碼示例。
示例1: avgdigamma
點讚 6
# 需要導入模塊: from sklearn import neighbors [as 別名]
# 或者: from sklearn.neighbors import BallTree [as 別名]
def avgdigamma(data, dvec, leaf_size=16):
"""Convenience function for finding expectation value of given
some number of neighbors in some radius in a marginal space.
Parameters
----------
points : numpy.ndarray
dvec : array_like (n_points,)
Returns
-------
avgdigamma : float
expectation value of
"""
tree = BallTree(data, leaf_size=leaf_size, p=float('inf'))
n_points = tree.query_radius(data, dvec - EPS, count_only=True)
return digamma(n_points).mean()
開發者ID:msmbuilder,項目名稱:mdentropy,代碼行數:20,
示例2: test_unsupervised_inputs
點讚 6
# 需要導入模塊: from sklearn import neighbors [as 別名]
# 或者: from sklearn.neighbors import BallTree [as 別名]
def test_unsupervised_inputs():
# test the types of valid input into NearestNeighbors
X = rng.random_sample((10, 3))
nbrs_fid = neighbors.NearestNeighbors(n_neighbors=1)
nbrs_fid.fit(X)
dist1, ind1 = nbrs_fid.kneighbors(X)
nbrs = neighbors.NearestNeighbors(n_neighbors=1)
for input in (nbrs_fid, neighbors.BallTree(X), neighbors.KDTree(X)):
nbrs.fit(input)
dist2, ind2 = nbrs.kneighbors(X)
assert_array_almost_equal(dist1, dist2)
assert_array_almost_equal(ind1, ind2)
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:19,
示例3: test_haversine
點讚 6
# 需要導入模塊: from sklearn import neighbors [as 別名]
# 或者: from sklearn.neighbors import BallTree [as 別名]
def test_haversine():
tree = BallTree(spatial_data[:, :2], metric="haversine")
dist_matrix, _ = tree.query(spatial_data[:, :2], k=spatial_data.shape[0])
test_matrix = np.array(
[
[
dist.haversine(spatial_data[i, :2], spatial_data[j, :2])
for j in range(spatial_data.shape[0])
]
for i in range(spatial_data.shape[0])
]
)
test_matrix.sort(axis=1)
assert_array_almost_equal(
test_matrix,
dist_matrix,
err_msg="Distances don't match " "for metric haversine",
)
開發者ID:lmcinnes,項目名稱:pynndescent,代碼行數:20,
示例4: test_haversine
點讚 6
# 需要導入模塊: from sklearn import neighbors [as 別名]
# 或者: from sklearn.neighbors import BallTree [as 別名]
def test_haversine(spatial_data):
tree = BallTree(spatial_data[:, :2], metric="haversine")
dist_matrix, _ = tree.query(spatial_data[:, :2], k=spatial_data.shape[0])
test_matrix = np.array(
[
[
dist.haversine(spatial_data[i, :2], spatial_data[j, :2])
for j in range(spatial_data.shape[0])
]
for i in range(spatial_data.shape[0])
]
)
test_matrix.sort(axis=1)
assert_array_almost_equal(
test_matrix,
dist_matrix,
err_msg="Distances don't match " "for metric haversine",
)
開發者ID:lmcinnes,項目名稱:umap,代碼行數:20,
示例5: make_propensity_lists
點讚 6
# 需要導入模塊: from sklearn import neighbors [as 別名]
# 或者: from sklearn.neighbors import BallTree [as 別名]
def make_propensity_lists