首页 > 代码库 > Python 聚类分析LinkedIn用户人脉网络
Python 聚类分析LinkedIn用户人脉网络
CODE:
#!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-8-26 @author: guaguastd @name: linkedin_network_clusters.py ''' import os import sys import json from urllib2 import HTTPError from cluster import KMeansClustering, centroid # A helper function to munge data and build up an XML tree sys.path.append(os.path.join(os.getcwd(), "e:", "eclipse", "LinkedIn", "dFile")) from mykml import createKML K = 3 # get geo code from geo import geo_from_bing g = geo_from_bing() # Load the data CONNECTIONS_DATA = http://www.mamicode.com/'E:/eclipse/LinkedIn/dfile/linkedin_connections.json'>
RESULT:[Location(Beijing, Beijing, China 39 54m 0.0s N, 116 23m 0.0s E)] [Location(Beijing, Beijing, China 39 54m 0.0s N, 116 23m 0.0s E)] None [Location(CA, United States 37 43m 0.0s N, 122 15m 0.0s W)] [Location(Birmingham, England, United Kingdom 52 29m 0.0s N, 1 55m 0.0s W), Location(Birmingham, England, United Kingdom 52 27m 0.0s N, 1 43m 0.0s W), Location(Birmingham Airport, England, United Kingdom 52 27m 0.0s N, 1 44m 0.0s W), Location(Birmingham Business Park, England, United Kingdom 52 28m 0.0s N, 1 43m 0.0s W)] [Location(Birmingham, England, United Kingdom 52 29m 0.0s N, 1 55m 0.0s W), Location(Birmingham, England, United Kingdom 52 27m 0.0s N, 1 43m 0.0s W), Location(Birmingham Airport, England, United Kingdom 52 27m 0.0s N, 1 44m 0.0s W), Location(Birmingham Business Park, England, United Kingdom 52 28m 0.0s N, 1 43m 0.0s W)] [Location(China 36 33m 0.0s N, 103 59m 0.0s E)] [Location(China 36 33m 0.0s N, 103 59m 0.0s E)] [Location(Chengdu, Sichuan, China 30 40m 0.0s N, 104 5m 0.0s E)] [Location(Chengdu, Sichuan, China 30 40m 0.0s N, 104 5m 0.0s E)] [Location(Xingtai, Hebei, China 37 4m 0.0s N, 114 29m 0.0s E)] [Location(Xingtai, Hebei, China 37 4m 0.0s N, 114 29m 0.0s E)] [Location(United States 39 27m 0.0s N, 98 57m 0.0s W)] [Location(United States 39 27m 0.0s N, 98 57m 0.0s W)] [Location(Foshan, Guangdong, China 23 2m 0.0s N, 113 6m 0.0s E)] [Location(Foshan, Guangdong, China 23 2m 0.0s N, 113 6m 0.0s E)] Data written to E:\eclipse\LinkedIn\dfile\linkedin_clusters_kmeans.kmlPython 聚类分析LinkedIn用户人脉网络
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。