π₯ λ°μ΄ν° μ λΆλ¬μ€κΈ°
- μ§νμ² μ μλ κ²½λ
- λ²μ€μ λ₯μ₯ μλ κ²½λ
- μκΆμ½λ μλ κ²½λ
import pandas as pd
market_area = pd.read_csv('./μκΆ_αα
©αΌαα
‘αΈαα
©α«(Center_Points).csv')
subway_stations = pd.read_csv('./μ΅μ’
_μ§νμ² _3κ°λ
_μΉνμ°¨.csv')
bus_stations = pd.read_csv('./αα
¬αα
©αΌ_αα
₯αα
³αα
¦αα
΅αα
₯+αα
₯αα
³αα
₯αΌα
α
²αα
‘αΌ_αα
±αα
§αΌαα
©_αα
‘αΉ(Bus_Points).csv')
β‘ market_area(μκΆ) λ°μ΄ν° νλ μ κ°κ°, μλ κ²½λ κ° μΆμΆ
# λ¬Έμμ΄μ μΌνλ₯Ό κΈ°μ€μΌλ‘ λΆν νμ¬ 'κ²½λ'μ 'μλ' μ»¬λΌ μμ±
market_area[['κ²½λ', 'μλ']] = market_area['μκΆ_μ€μμκ²½λ_κ°'].str.split(', ', expand=True)
market_area[['κ²½λ', 'μλ']] = market_area[['κ²½λ', 'μλ']].astype(float)
market_area.head(3)
β‘ market_area(μκΆ) λ°μ΄ν° νλ μ : μκΆμ½λ λ³ κ²½λμ μλ κ° μΆμΆ
μκΆ μ€μ¬ μ’ν 리μ€νΈμ μ μ₯(μ€λ³΅μμ )
markets = market_area[['μκΆ_μ½λ','κ²½λ', 'μλ']]
markets = markets.drop_duplicates().sort_values(by = 'μκΆ_μ½λ')
market_list = list(zip(markets['κ²½λ'], markets['μλ']))
market_list[:3]
β‘ subway & bus λ°μ΄ν° νλ μ : μκΆμ½λ λ³ κ²½λμ μλ κ° μΆμΆ
μ§νμ² μ μ’ν 리μ€νΈμ μ μ₯(μ€λ³΅μμ )
sub_temp = subway_stations[['μλ', 'κ²½λ']]
sub_temp = sub_temp.drop_duplicates()
sub_list = list(zip(sub_temp['κ²½λ'], sub_temp['μλ']))
sub_list[:3]
len(sub_list)
λ²μ€μ λ₯μ₯ μ’ν 리μ€νΈμ μ μ₯(μ€λ³΅μμ )
display(bus_stations.head(3), bus_stations.info())
bus_stations = bus_stations.dropna()
bus_stations.info()
bus_temp = bus_stations[['Xμ’ν', 'Yμ’ν']]
bus_temp = bus_temp.drop_duplicates()
bus_list = list(zip(bus_temp['Yμ’ν'], bus_temp['Xμ’ν']))
bus_list[:3]
len(bus_list)
β‘ μκΆ μ’ν 500λ―Έν° μ΄λ΄ μ§νμ² μ, λ²μ€μ λ₯μ₯ κ°μλ₯Ό λ°ν
- market_summaryμ κΈ°μ€μ΄ λλ μκΆμ½λμ μκΆλ³ μλμ κ²½λ μ μ₯
market_summary = markets[['μκΆ_μ½λ', 'κ²½λ', 'μλ']]
market_summary.head(3)
- geopy λΌμ΄λΈλ¬λ¦¬λ₯Ό μ¬μ©νμ¬, μκΆμ’ν - μ§νμ² μ/λ²μ€μ λ₯μ₯ μ¬μ΄μ 거리λ₯Ό μΈ‘μ νμ¬
- λ°κ²½ 500λ―Έν° μμ λ€ κ²½μ°, μ§νμ² μ/λ²μ€μ λ₯μ₯ κ°μλ₯Ό count νλ ν¨μ μ μ
- market_summary λ°μ΄ν°νλ μμ μκΆμ½λλ³ λ°κ²½ 500λ―Έν° μ§νμ² μ/λ²μ€μ λ₯μ₯ κ°μ μ»¬λΌ μΆκ°
from geopy.distance import geodesic
def within_radius(center, target):
return geodesic(center, target).meters <= 500
def count_bus_stations_within_radius(market_list, bus_list):
bus_count = 0
for station in bus_list:
if any(within_radius(market, station) for market in market_list):
bus_count += 1
return bus_count
def count_sub_stations_within_radius(market_list, sub_list):
sub_count = 0
for station in sub_list:
if any(within_radius(market, station) for market in market_list):
sub_count += 1
return sub_count
market_summary['μ§νμ² μ_μ'] = [count_sub_stations_within_radius([market], sub_list) for market in market_list]
market_summary['λ²μ€μ λ₯μ₯_μ'] = [count_bus_stations_within_radius([market], bus_list) for market in market_list]
μκΆ λΆλ₯ν
- k-means clustering μΌλ‘ μ μλ―Έν΄λ³΄μ΄λ λ³μλ³λ‘ κ΅°μ§ν μλ ->> μ λλ‘ λ κ΅°μ§μ΄ λμ€μ§ μλ μ€
- μ§κ° μμ€ μ ν : λ€μν μκΆλΆμ μλΉμ€ λ΄μ μ§κ° μμ€ μ€, μλ―Έμμ κ²μΌλ‘ μμλλ μ§κ° μμ€ λΆλ₯, μ ν
- 골λͺ©μκΆμ λ°°νμ§ λ°μ΄ν°(μ§κ°μμ€ νμ ) λ³ν© μμ
09.11 μ λ°μ΄νΈ μ¬ν β‘ λ³Έ ν¬μ€ν μ κ²°κ³Ό λ°μ΄ν° μ¬μ©νμ§ μμ
- μκΆ μ€μ μ§μ μ λ°κ²½ λ΄ μ§νμ² μ μ / λ²μ€μ λ₯μ₯ μ λ°μ΄ν°λ μ¬μ©νμ§ μκΈ°λ‘ κ²°μ νλ€.
- μ΄μ λ, κΈ°λ³Έμ μΌλ‘ μκΆμ μ νν λ©΄μ λ΄μ μ§κ³λ λ°μ΄ν°λ₯Ό μμ§νκ³ μμκΈ° λλ¬Έμ λμΌν λ°©μμΌλ‘ λ°κ²½ κ°λ μ νκΈ°νκ³ 'μμλ΄' κ°λ μΌλ‘ μ§νμ² μ μμ λ²μ€μ λ₯μ₯ μλ₯Ό μ§κ³νκΈ°λ‘ νλ€.
728x90