当前位置: 首页 > news >正文

ESDA in PySal (1) 利用 A-DBSCAN 聚类点并探索边界模糊性

ESDA in PySAL (1) 利用 A-DBSCAN 聚类点并探索边界模糊性

在本例中,我们将以柏林的 AirBnb 房源样本为例,说明如何使用 A-DBSCAN (Arribas-Bel et al., 2019)。A-DBSCAN 可以让我们做两件事:

  • 识别高密度 AirBnb 房源集群并划定其边界
  • 探索这些边界的稳定性
%matplotlib inlineimport pandas
import geopandas
import numpy as np
import contextily as cx
import matplotlib.pyplot as plt
from shapely.geometry import Polygon
from libpysal.cg.alpha_shapes import alpha_shape_autoimport sys
sys.path.append("../")
try:from esda.adbscan import ADBSCAN, get_cluster_boundary, remap_lbls
# This below can be removed once A-DBSCAN is merged into `esda`
except:print("Import from local folder...")import syssys.path.append("../esda")from adbscan import ADBSCAN, get_cluster_boundary, remap_lbls

数据

我们将使用 Inside Airbnb 中的柏林提取数据。这与 Scipy 2018 tutorial on Geospatial data analysis with Python中使用的数据集相同。

tab = pandas.read_csv("data/berlin-listings.csv")
tab.head(2)
Unnamed: 0idlisting_urlscrape_idlast_scrapednamesummaryspacedescriptionexperiences_offered...review_scores_valuerequires_licenselicensejurisdiction_namesinstant_bookablecancellation_policyrequire_guest_profile_picturerequire_guest_phone_verificationcalculated_host_listings_countreviews_per_month
0017260587https://www.airbnb.com/rooms/17260587201705072222352017-05-08Kunterbuntes Zimmer mit eigenem Bad für jedermannMeine Unterkunft ist gut für paare, alleinreis...NaNMeine Unterkunft ist gut für paare, alleinreis...none...10.0fNaNNaNtflexibleff32.00
1117227881https://www.airbnb.com/rooms/17227881201705072222352017-05-08Modernes Zimmer in Berlin PankowEs ist ein schönes gepflegtes und modernes Zim...Das Haus befindet sich direkt vor eine Tram Ha...Es ist ein schönes gepflegtes und modernes Zim...none...10.0fNaNNaNtflexibleff11.29

2 rows × 96 columns

原始数据集包括 20,000 多个观测值:

tab.shape
(20053, 96)

为了让图解在任何硬件上运行得更快一些,让我们随机抽取 10%的样本,即随机抽取 2,000 个属性:

tab = tab.sample(n=2000, random_state=1234)

为方便起见,我们将其转换为 “GeoDataFrame”,其中的几何图形是根据原始表格中的长/纬度列建立的:

db_ll = geopandas.GeoDataFrame(tab,geometry=geopandas.points_from_xy(tab.longitude, tab.latitude),crs={'init': 'epsg:4326'})
/home/serge/anaconda3/envs/analytical/lib/python3.7/site-packages/pyproj/crs/crs.py:53: FutureWarning: '+init=<authority>:<code>' syntax is deprecated. '<authority>:<code>' is the preferred initialization method. When making the change, be mindful of axis order changes: https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6return _prepare_from_string(" ".join(pjargs))

因为我们要运行一个依赖于距离的算法,所以我们需要能够在投影平面上计算这些距离。我们使用为德国设计的ETRS89投影来代替原始的长/纬度坐标,并以米为单位:

db = db_ll.to_crs(epsg=5243)

*现在我们可以将数据集可视化了:

ax = db.plot(markersize=0.1, color='orange')
cx.add_basemap(ax, crs=db.crs.to_string());

http://www.lryc.cn/news/156080.html

相关文章:

  • 利用GitHub实现域名跳转
  • 【Linux详解】——共享内存
  • Golang 几个不错的实用函数库
  • 【Linux】地址空间概念
  • 视频集中存储/直播点播平台EasyDSS点播文件分类功能新升级
  • JavaScript基础06——let和var两个关键字有啥不同
  • Apache Doris 2.0.1 1.2.7 版本正式发布!
  • YOLOv5算法改进(11)— 替换主干网络之EfficientNetv2
  • Lombok讲解
  • 【Android】功能丰富的dumpsys activity
  • 亚马逊云科技 云技能孵化营——我的云技能之旅
  • 南大通用数据库-Gbase-8a-学习-38-常规日志(general log)
  • 汽车信息安全导图
  • 【元宇宙】区块链,元宇宙最大化的驱动力
  • $ref属性的介绍与使用
  • Holistic Evaluation of Language Models
  • android 布局 横屏 android横屏适配
  • 北京已收录2023开学了《乡村振兴战略下传统村落文化旅游设计》中国建筑出版传媒许少辉八一新书
  • 【Linux】Ubuntu20.04版本配置pytorch环境2023.09.05【教程】
  • 11 Python的正则表达式
  • 关于工信部发布的app备案以及小程序备案流程
  • 【高等数学基础知识篇】——不定积分
  • python使用鼠标在图片上画框
  • 算法通关村第十五关:青铜-用4KB内存寻找重复元素
  • SQL注入 - 宽字节注入
  • Flink基础
  • javaee spring aop 注解实现
  • Qt应用开发(基础篇)——按钮基类 QAbstractButton
  • 2023年最新的 前端面试题(个人总结)
  • 服务器基本故障排查方法