用于跨信用案件分配的包。
Icics的Python项目详细描述
徐静
跨信用智能分类系统(ICICS)。 这是一个相互信任的python包。你可以用它把案子交给你的工薪阶层。
简介
首先简单描述算法的过程:
- 首先,定义目标法律“偏好”案例(例如,法律以高回收率操作案例,并在案例中考虑法律“偏好”)
- 准备分配的随机中断案例序列(该操作主要削弱了算法使用的缺点)
- 聚类算法是针对目标法律“偏好”案例进行的,它将相似的案例集合在一起。并记录每个集群的中心数和每个集群中的案例数
- 计算每个案例与目标法则之间的相似度,将案例分配给一个高相似度的聚类,并记录相似度。
- 每一类案件的相似性,选择在每一类案件中具有高度相似性的$K(n_i/n)$作为待分配案件的法律案件的对象(其中$K$表示案件为家庭的法律案件的分配,$N_i$表示目标是在每一类案件中“喜欢”案件的数量,$N$表示所有法律历史的目标“喜欢”产品的数量)
- 删除法律对象和法律对象指定的案件,并执行下一个目标案件的指定。
更多的细节你可以在你的设备中点击这个包,还有更多关于ICIC的信息。
演示
import numpy as np import pandas as pd from sklearn.cluster import KMeans from sklearn.cross_validation import StratifiedKFold import random import matplotlib.pyplot as plt import seaborn as sns from icics import * #test the model train = pd.read_csv(u"C:/Users/Administrator.USER-20170417DX/Desktop/test1.csv") df = train.copy() dfold0 = train.iloc[range(1000)] df0 = train.iloc[range(1000,2000)].drop('ywy0',axis=1) topn0 = pd.DataFrame({'ywy0':np.unique(dfold0.ywy0),'topn_ywy': [30,50,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,20,60]}) bhywy0 = pd.DataFrame({'ywy0':dfold0.ywy0}) icic(dfold0,df0,topn0,bhywy0,ncluster=2,shuffle=1,epsilon=0.001,init='k-means++',random_state=123,max_iter=1000,algorithm="auto",path=0)
然后您可以使用acc平均值的方法来训练超参数:
#train the model train = pd.read_excel(u"C:/Users/Administrator.USER-20170417DX/Desktop/test2.xlsx") bhywy = pd.DataFrame({'ywy0':train.ywy0}) topn = pd.DataFrame({'ywy0':['cc12','cd17'],'topn_ywy':[30,40]}) pre_mean=[] for j in np.arange(1,15): means = acc_mean(train,bhywy,topn,j) pre_mean.append(means) precies = pd.DataFrame({'ncluster' : np.arange(1,15),'acc_mean' : pre_mean}) plt.figure(1,figsize=(14,14)) with sns.axes_style("ticks"): plt.title('The acc_mean of the icics-model') sns.pointplot(x='ncluster',y='acc_mean',data=precies) plt.xlabel('Number of Cluster') plt.ylabel('Mean of accuracy') plt.show()
结果如下:
这些演示代码csan不适用于新版本>;=3.4.3,您应该在包中看到帮助文档, 你也可以在https://icics-doc.readthedocs.io/en/latest/