-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproduceOutput.py
49 lines (25 loc) · 1.08 KB
/
produceOutput.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
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import pandas as pd
import numpy as np
# In[ ]:
class produce_output():
def __init__(self):
pass
def convert_to_category(self,data,result_matrix):
argmax = lambda x: x.argmax()
argmax_applied= list(map(argmax, result_matrix))
array_result=np.array(result_matrix)
max_prob=array_result.max(axis=1)
full_cat=pd.read_csv("full_cat.csv")
result=pd.DataFrame(argmax_applied)
result["max_prob"]=max_prob
# result["pieces"]=parts
result=result.merge(full_cat,left_on=0,right_on="new_cat",how="left")
result=result[[0,"_key_x","_key_y","_key"]]
total_result=pd.concat([data,result],axis=1)
total_result=total_result[["PNM",0,"_key_x","_key_y","_key"]]
total_result.columns=["상품명","카테고리넘버","대분류","중분류","소분류"]
total_result=total_result.fillna(" ")
return total_result