etc

์ง์› ํ‡ด์‚ฌ ์—ฌ๋ถ€ ์˜ˆ์ธก ํ”„๋กœ๊ทธ๋žจ (with ClickAI) Python(ํŒŒ์ด์ฌ)

ํ•œ์ฝ”๋”ฉ 2020. 7. 16. 14:14
728x90
728x90
์ž๋ฃŒ ๋ฐ์ดํ„ฐ

๋‚˜์ด / ์ถœ์žฅ / ์ผ๋‹น / ๋ถ„์•ผ / ์ง‘๊นŒ์ง€์˜ ๊ฑฐ๋ฆฌ / ๊ต์œก / ๊ต์œก๋ถ„์•ผ / ๊ทผ๋ฌด ํ™˜๊ฒฝ / ์„ฑ๋ณ„ / ์ง์—…์ฐธ์—ฌ / ์ง์—… ๋ ˆ๋ฒจ / ์ง๋ฌด / ์ง์—…์•ˆ์ „๋„ / ๊ฒฐํ˜ผ ์—ฌ๋ถ€ / ์›”์†Œ๋“ / ์ผํ•œ ํšŒ์‚ฌ ์ˆ˜ / ์ดˆ๊ณผ๊ทผ๋ฌด / ์—ฐ๋ด‰์ธ์ƒ๋น„์œจ / ์„ฑ๋Šฅ๋“ฑ๊ธ‰ / ๊ด€๊ณ„๋งŒ์กฑ๋„ / ์Šคํ†ก์˜ต์…˜๋ ˆ๋ฒจ / ์ด๊ทผ๋ฌด๋…„๋„ / ์ž‘๋…„ ๊ต์œก์‹œ๊ฐ„ / ์›Œ๋ผ๋ฒจ / ํšŒ์‚ฌ์—์„œ ๊ทผ์†๋…„์ˆ˜ / ํ˜„์žฌ ์—ญํ• ์ˆ˜ / ๋งˆ์ง€๋ง‰ ์Šน์ง„ ์ดํ›„ ๋ช‡๋…„ / ํ˜„์žฌ ๊ด€๋ฆฌ์ž์™€ ํ•จ๊ป˜ ๋ช‡๋…„

์†Œ์Šค์ฝ”๋“œ
import requests
import json

url = "https://api.clickai.ai/889/predict/"

payload = {"modelid":10081,
           "apptoken":"e36aeab7d264456c9a97e49cc09db174",
           "parameter": {"๋‚˜์ด__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": int(input('๋‚˜์ด : '))
                         ,"์ถœ์žฅ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": input('์ถœ์žฅ (Non-Travel / Travel_Rarely) :  ')
                         ,"์ผ๋‹น__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": int(input('์ผ๋‹น : '))
                         ,"๋ถ„์•ผ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": input('๋ถ„์•ผ (Sales/Human Resources/Research & Development) : ')
                         ,"์ง‘๊นŒ์ง€์˜ ๊ฑฐ๋ฆฌ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": int(input('์ง‘๊นŒ์ง€์˜ ๊ฑฐ๋ฆฌ(km) : '))
                         ,"๊ต์œก__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv":int(input('๊ต์œก (๋…„) : '))
                         ,"๊ต์œก๋ถ„์•ผ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": input('๊ต์œก ๋ถ„์•ผ (Marketing/Medical/Technical Degree/Life Sciences) : ')
                         ,"๊ทผ๋ฌด ํ™˜๊ฒฝ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv":int(input('๊ทผ๋ฌด ํ™˜๊ฒฝ ๋งŒ์กฑ๋„ (1~5) : '))
                         ,"์„ฑ๋ณ„__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": input('์„ฑ๋ณ„ (Female/Male) : ')
                         ,"์ง์—…์ฐธ์—ฌ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv":int(input('์ง์—… ์ฐธ์—ฌ๋„ (1~5) : '))
                         ,"์ง์—… ๋ ˆ๋ฒจ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv":int(input('์ง์—… ์ˆ™๋ จ๋„ (1~5) : '))
                         ,"์ง๋ฌด__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": input('์ง๋ฌด (Sales Executive/Manager/Laboratory Technician/Manufacturing Director) : ')
                         ,"์ง์—…์•ˆ์ „๋„__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv":int(input('์ง์—… ์•ˆ์ „๋„ (1~5) : '))
                         ,"๊ฒฐํ˜ผ ์—ฌ๋ถ€__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": input('๊ฒฐํ˜ผ ์—ฌ๋ถ€ (Married/Single) : ')
                         ,"์›”์†Œ๋“__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": int(input('์›”์†Œ๋“ (๋งŒ ์›) : '))
                         ,"์ผํ•œ ํšŒ์‚ฌ์ˆ˜__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv":int(input('ํšŒ์‚ฌ ์ด์ง ์ˆ˜ : '))
                         ,"์ดˆ๊ณผ๊ทผ๋ฌด__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": input('์ดˆ๊ณผ๊ทผ๋ฌด (Yes/No) : ')
                         ,"์—ฐ๋ด‰์ธ์ƒ๋น„์œจ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv":int(input('์—ฐ๋ด‰ ์ธ์ƒ ๋น„์œจ (%) : '))
                         ,"์„ฑ๋Šฅ๋“ฑ๊ธ‰__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv":int(input('์ง์› ๋Šฅ๋ ฅ (1~5) : '))
                         ,"๊ด€๊ณ„๋งŒ์กฑ๋„__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": int(input('ํšŒ์‚ฌ ๋‚ด ์ธ๊ฐ„ ๊ด€๊ณ„ ๋งŒ์กฑ๋„ (1~5) : '))
                         ,"์Šคํ†ก์˜ต์…˜๋ ˆ๋ฒจ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": int(input('์Šคํ†ก์˜ต์…˜ ๋ ˆ๋ฒจ (0~1) : '))
                         ,"์ด๊ทผ๋ฌด๋…„๋„__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": int(input('์ด ๊ทผ๋ฌด๋…„๋„ : '))
                         ,"์ž‘๋…„ ๊ต์œก์‹œ๊ฐ„__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": int(input('์ž‘๋…„ ๊ต์œก์‹œ๊ฐ„ : '))
                         ,"์›Œ๋ผ๋ฒจ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": int(input('์›Œ๋ผ๋ฒจ ๋งŒ์กฑ๋„ (1~5) : '))
                         ,"ํšŒ์‚ฌ์—์„œ ๊ทผ์†๋…„์ˆ˜__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": int(input('ํšŒ์‚ฌ ๊ทผ์†๋…„์ˆ˜ : '))
                         ,"ํ˜„์žฌ ์—ญํ• ์ˆ˜__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": int(input('๋ถ€์„œ ๋‚ด ํ˜„์žฌ ์—ญํ• ์ˆ˜ : '))
                         ,"๋งˆ์ง€๋ง‰ ์Šน์ง„ ์ดํ›„ ๋ช‡๋…„__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": int(input('๋งˆ์ง€๋ง‰ ์Šน์ง„ ์ดํ›„ ๋ช‡ ๋…„ ์ผํ–ˆ๋Š”๊ฐ€? : '))
                         ,"ํ˜„์žฌ ๊ด€๋ฆฌ์ž์™€ ํ•จ๊ป˜ ๋ช‡๋…„__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": int(input('ํ˜„์žฌ ๊ด€๋ฆฌ์ž์™€ ํ•จ๊ป˜ ๋ช‡ ๋…„ ํ•จ๊ป˜ ์ผํ–ˆ๋Š”๊ฐ€? : '))
                        }
          }

headers = {
    'content-type': "application/json",
    'cache-control': "no-cache",
    }

response = requests.request("POST", url, data=json.dumps(payload), headers=headers)

print(response.text.split('n')[6][14:20])

print("\n์ง์› ํ‡ด์‚ฌ ์—ฌ๋ถ€")
if(response.text.split('n')[1][31] == 'N'):
    print(response.text.split('n')[1][31:33])
else:
    print(response.text.split('n')[1][31:34])

 

์˜ˆ์ œ ๋ฐ์ดํ„ฐ ๋ฏธ๋ฆฌ ์ž…๋ ฅํ•œ ์†Œ์Šค์ฝ”๋“œ
import requests
import json

url = "https://api.clickai.ai/889/predict/"

payload = {"modelid":10081,
           "apptoken":"e36aeab7d264456c9a97e49cc09db174",
           "parameter": {"๋‚˜์ด__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 31
                         ,"์ถœ์žฅ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": "Non-Travel"
                         ,"์ผ๋‹น__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 1188
                         ,"๋ถ„์•ผ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": "Sales"
                         ,"์ง‘๊นŒ์ง€์˜ ๊ฑฐ๋ฆฌ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 20
                         ,"๊ต์œก__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 2
                         ,"๊ต์œก๋ถ„์•ผ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": "Marketing"
                         ,"๊ทผ๋ฌด ํ™˜๊ฒฝ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv":4
                         ,"์„ฑ๋ณ„__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": "Female"
                         ,"์ง์—…์ฐธ์—ฌ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 3
                         ,"์ง์—… ๋ ˆ๋ฒจ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 2
                         ,"์ง๋ฌด__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": "Sales Executive"
                         ,"์ง์—…์•ˆ์ „๋„__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 3
                         ,"๊ฒฐํ˜ผ ์—ฌ๋ถ€__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": "Married"
                         ,"์›”์†Œ๋“__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 6932
                         ,"์ผํ•œ ํšŒ์‚ฌ์ˆ˜__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 1
                         ,"์ดˆ๊ณผ๊ทผ๋ฌด__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": "No"
                         ,"์—ฐ๋ด‰์ธ์ƒ๋น„์œจ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 13
                         ,"์„ฑ๋Šฅ๋“ฑ๊ธ‰__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 3
                         ,"๊ด€๊ณ„๋งŒ์กฑ๋„__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 4
                         ,"์Šคํ†ก์˜ต์…˜๋ ˆ๋ฒจ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 1
                         ,"์ด๊ทผ๋ฌด๋…„๋„__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 9
                         ,"์ž‘๋…„ ๊ต์œก์‹œ๊ฐ„__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 2
                         ,"์›Œ๋ผ๋ฒจ__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 2
                         ,"ํšŒ์‚ฌ์—์„œ ๊ทผ์†๋…„์ˆ˜__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 9
                         ,"ํ˜„์žฌ ์—ญํ• ์ˆ˜__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 8
                         ,"๋งˆ์ง€๋ง‰ ์Šน์ง„ ์ดํ›„ ๋ช‡๋…„__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 0
                         ,"ํ˜„์žฌ ๊ด€๋ฆฌ์ž์™€ ํ•จ๊ป˜ ๋ช‡๋…„__์ง์› ํ‡ด์‚ฌ์—ฌ๋ถ€.csv": 0
                        }
          }

headers = {
    'content-type': "application/json",
    'cache-control': "no-cache",
    }

response = requests.request("POST", url, data=json.dumps(payload), headers=headers)

print("\nํ‡ด์‚ฌํ•  ํ™•๋ฅ ")
print(response.text.split('n')[6][14:20])

print("\n์ง์› ํ‡ด์‚ฌ ์—ฌ๋ถ€")
if(response.text.split('n')[1][31] == 'N'):
    print(response.text.split('n')[1][31:33])
else:
    print(response.text.split('n')[1][31:34])

 

์˜ˆ์ œ ๋ฐ์ดํ„ฐ ๊ฒฐ๊ณผ

728x90
๋ฐ˜์‘ํ˜•