本文整理汇总了Python中bigml.api.BigML.download_dataset方法的典型用法代码示例。如果您正苦于以下问题:Python BigML.download_dataset方法的具体用法?Python BigML.download_dataset怎么用?Python BigML.download_dataset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bigml.api.BigML
的用法示例。
在下文中一共展示了BigML.download_dataset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Cluster
# 需要导入模块: from bigml.api import BigML [as 别名]
# 或者: from bigml.api.BigML import download_dataset [as 别名]
#.........这里部分代码省略.........
for point in list_of_points:
centroid_id = None
if isinstance(point, Centroid):
centroid_id = point.centroid_id
point = point.center
by_name = False
clean_point, unique_terms = self._prepare_for_distance( \
point, by_name=by_name)
if clean_point != reference_point:
result = {"data": point, "distance": reference.distance2( \
clean_point, unique_terms, self.scales)}
if centroid_id is not None:
result.update({"centroid_id": centroid_id})
distances.append(result)
return distances
def points_in_cluster(self, centroid_id):
"""Returns the list of data points that fall in one cluster.
"""
cluster_datasets = self.datasets
centroid_dataset = cluster_datasets.get(centroid_id)
if self.api is None:
self.api = BigML(storage=STORAGE)
if centroid_dataset in [None, ""]:
centroid_dataset = self.api.create_dataset( \
self.resource_id, {"centroid": centroid_id})
self.api.ok(centroid_dataset)
else:
centroid_dataset = self.api.check_resource( \
"dataset/%s" % centroid_dataset)
# download dataset to compute local predictions
downloaded_data = self.api.download_dataset( \
centroid_dataset["resource"])
if PY3:
text_reader = codecs.getreader("utf-8")
downloaded_data = text_reader(downloaded_data)
reader = csv.DictReader(downloaded_data)
points = []
for row in reader:
points.append(row)
return points
def closest_in_cluster(self, reference_point,
number_of_points=None,
centroid_id=None,
by_name=True):
"""Computes the list of data points closer to a reference point.
If no centroid_id information is provided, the points are chosen
from the same cluster as the reference point.
The points are returned in a list, sorted according
to their distance to the reference point. The number_of_points
parameter can be set to truncate the list to a maximum number of
results. The response is a dictionary that contains the
centroid id of the cluster plus the list of points
"""
if centroid_id is not None and centroid_id not in \
[centroid.centroid_id for centroid in self.centroids]:
raise AttributeError( \
"Failed to find the provided centroid_id: %s" % centroid_id)
if centroid_id is None:
# finding the reference point cluster's centroid
centroid_info = self.centroid(reference_point, by_name=True)
centroid_id = centroid_info["centroid_id"]
# reading the points that fall in the same cluster