def getBayesIndex(): csv = glp.getFinalCsv() oriIndex = csv.keys() newIndex = [] for each in oriIndex: newIndex.append(each + 'Type') return newIndex
def reshapeCsv(): leftFacEng, leftFacChi = getleftFac() csv = glp.getFinalCsv() copy = csv.copy() for each in leftFacEng: typeName = copy[each] t1 = int(typeName.quantile(1 / 5)) t2 = int(typeName.quantile(2 / 5)) t3 = int(typeName.quantile(3 / 5)) t4 = int(typeName.quantile(4 / 5)) t5 = int(typeName.quantile(5 / 5)) typeList = [] for col in typeName: if col in range(0, t1 + 1): typeList.append('type1') elif col in range(t1 + 1, t2 + 1): typeList.append('type2') elif col in range(t2 + 1, t3 + 1): typeList.append('type3') elif col in range(t3 + 1, t4 + 1): typeList.append('type4') elif col in range(t4 + 1, t5 + 1): typeList.append('type5') copy[each + 'Type'] = typeList return copy
def getOriType(coordinate,facType): global codeDict global ak url = 'http://restapi.amap.com/v3/place/around?key='+ ak +'&location='+coordinate[0]+','+coordinate[1]+'&types='+ codeDict[facType] +'&radius='+str(gp.getMetParam())\ +'&offset=20&page=1&extensions=base' count = waitRequest(url) csv = glp.getFinalCsv() copy = csv.copy() typeName = copy[facType] t1 = int(typeName.quantile(1/5)) t2 = int(typeName.quantile(2/5)) t3 = int(typeName.quantile(3/5)) t4 = int(typeName.quantile(4/5)) t5 = int(typeName.quantile(5/5)) if count in range(0,t1+1): return 'type1' elif count in range(t1+1,t2+1): return 'type2' elif count in range(t2+1,t3+1): return 'type3' elif count in range(t3+1,t4+1): return 'type4' elif count in range(t4+1,t5+1): return 'type5'
def getleftList(): leftList = [] global random20List csvSize = len(glp.getFinalCsv()) for i in range(0, csvSize): if i not in random20List: leftList.append(i) return leftList
def getrandom20List(): global random20List random20List.clear() csvSize = len(glp.getFinalCsv()) for i in range(0, predicNum): r = random.randint(0, csvSize) if r in random20List: r = r - 1 continue random20List.append(r)
def getCsvIndex(facType): csv = glp.getFinalCsv() oriIndex = csv.keys() newIndex = [] leftLabelList = [] for each in oriIndex: newIndex.append(each + 'Type') oriIndexList = oriIndex.tolist() oriIndexList.remove(facType) leftSampleList = oriIndexList leftLabelList.append(facType + 'Type') #获取的是分类type #leftLabelList.append(facType) #获取的是原来的数据 return leftSampleList, leftLabelList