-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecommend_getPercent.py
62 lines (54 loc) · 1.64 KB
/
recommend_getPercent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import os
## 개행문자 제거
def delNewLine(li) :
newList = []
for i in li :
cramps =0
cramps = i.find('>')
newline = 0
newline = i.find('\n')
if(newline != -1) :
newList.append(i[cramps+2:newline])
else :
newList.append(i[cramps+2: ])
return newList
# 파일 경로
filePath = 'C:/Users/shdbt/Desktop/DATAFILE/학술제/추천시스템_관악구/simulation_19/'
fileName = '관악구_recommend'
file = filePath + fileName + '.txt'
# 000_recommend.txt 파일 갯수
LEN = 15
STANDARD = 0.6 ## 기준점 : 단위 킬로미터
for i in range(LEN) :
# 개행문자 제거하기
file = filePath + fileName + str(i) + '.txt'
r = open(file, 'r')
short_dist = r.readlines()
short_dist = delNewLine(short_dist)
# 파일에서 거리 획득하기
for i in range(len(short_dist)):
short_dist[i] = float(short_dist[i])
# 비율 계산
count = 0
for i in short_dist :
if(i <= STANDARD) :
count += 1
# 비율 계산 후 시각화
percent = count/len(short_dist)
print("{}% is available".format(int(percent*100)))
r.close()
# # 개행문자 제거하기
# r = open(file, 'r')
# short_dist = r.readlines()
# short_dist = delNewLine(short_dist)
# # 파일에서 거리 획득하기
# for i in range(len(short_dist)):
# short_dist[i] = float(short_dist[i])
# # 비율 계산
# count = 0
# standardDist = 0.6 ## 기준점 : 단위 킬로미터
# for i in short_dist :
# if(i <= standardDist) :
# count += 1
# percent = count/len(short_dist)
# print("{}% is available".format(int(percent*100)))