-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathESNB.py
42 lines (36 loc) ยท 1.61 KB
/
ESNB.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
import pandas as pd
from collections import Counter
def tolist(data): #2๋ฒ์งธ ์ด๋ง ์ฆ, label์ด๋ผ๊ณ ์ ํ ์ด๋ง ๋ฝ์์ ๋ฆฌ์คํธ๋ก
cat = data['label']
cat_list = cat.values.tolist()
return cat_list
def make_list(l,c, d, e,f,k): #๊ฐ output์ ๋์ผํ label์ ์ถ๋ก ํ ๊ฒ๋ผ๋ฆฌ ๋ฆฌ์คํธ๋ก ๋ง๋ค์ด์ค
com = []
for i in range(len(c)):
com.append([l[i],c[i], d[i], e[i],f[i],k[i]])
return com
def most(list): #๊ฐ ๋จ์ด๋ค์ ์นด์ดํธํด์ ์ต๋น๊ฐ ๋ง๋ค์ด์ฃผ๋๊ฑฐ
most2 = []
for i in list:
count = Counter(i)
most = count.most_common(n=1)
print(most[0])
most2.append(most[0][0]) #[('Life', 3), ('is', 3), ('too', 4), ('short', 5)]์ด๋ฐ์์ผ๋ก ๋์์ ์ธ๋ฑ์ค์ฒ๋ฆฌ๋ฅผ ๋จ์ด์ ๋ง์ถฐ์ ํด์ค
return most2 #๋ง์ฝ ํด๋น ๋จ์ด๊ฐ ๋ช๋ฒ ๋์๋ ๋ณด๋ ค๋ฉด [0]ํ๋ ์ง์ฐ๋ฉด ๋จ ๊ทผ๋ฐ ์ด์ฐจํผ ์ง๊ธ์ output 2๊ฐ๋ผ ์๋ฏธ ์๊ธดํจ
data = pd.read_csv('./four_check-point-447300.csv')
data0 = pd.read_csv('./three_check-point-339948.csv')
data1 = pd.read_csv('./three_check-point-250488.csv')
data2 = pd.read_csv("./first_check-point-250488.csv")
data3 = pd.read_csv("./first_check-point-286272.csv")
data4 = pd.read_csv("./second_check-point-232596.csv")
k = tolist(data)
a = tolist(data0) #csvํ์ผ์ด 2๊ฐ๋ผ ๊ทธ๋ฅ ๋๊ฐ์๊ฑฐ๋ก ์
b = tolist(data1)
c = tolist(data2)
d = tolist(data3)
e = tolist(data4)
com = make_list(k,a, b, c,d,e)
last = most(com)
submit = pd.read_csv('C:/Users/tm011/PycharmProjects/pythonProject1/sample_submission.csv')
submit['label'] = last
submit.to_csv('./submission_esnb_sota_FINAL.csv', index=False)