基于事务历史的客户机聚类研究项目
geot-cluster的Python项目详细描述
模块名称代表地理事务聚类。本模块是该方法的一个实现,是为HSE大学第三课程项目开发的。它将数据帧与 指定格式并返回群集列表。在
为了记录在案,它打算以这种形式供公众使用,因为它是一个研究项目,寻求解决所述问题的方法
安装
运行以下程序进行安装:
''Python
pip install geot_cluster’’’
使用
在使用之前,请确保您的数据集符合要求。Csv文件必须包含以下列才能正常工作
- user_id:字符串类型,例如:“423156821”
- event_dt:字符串类型,例如:“20190312”
- 事件时间:字符串类型,例如:“2019-03-12 06:24:00.279”
- 晶格:浮点型,例如:49.862621
- 长度:见晶格
工作流程:
import geot_cluster import markov_clustering as mc import matplotlib.pyplot as plt import networkx as nx path = [path to file with data] data, names = geot_cluster.data_load(path) %matplotlib notebook base = [path to the folder, where to store libs with information about clients] archivate = True libs= True graph_f = True cluster_f = True if(archivate): geot_cluster.archivate_maps(data, names, levels=4) if(libs): lib = geot_cluster.graph_preparation(data, names, base) prob_lib = geot_cluster.znakomstvo_by_lib(lib,data) lib, prob_lib = load_libs(base = base) if(graph_f): graph = geot_cluster.graph_forming(lib, prob_lib, treshold=0.9) if(cluster_f): result = mc.run_mcl(graph,pruning_threshold=0.7, inflation=2,expansion=2) clusters = mc.get_clusters(result) clust_0 = clusters_to_ids(lib=lib, prob_lib=prob_lib, clusters = clusters, number = 0) maps = get_cluster_maps(data = data, clust = clust_0) print("Number of clusters", len(clusters)) plt.figure(figsize=(10,10)) mc.drawing.draw_graph(result, clusters, edge_color="red",node_size=15,width = 1, with_labels=True, font_size = 8)
- 项目
标签: