๋ฐ˜์‘ํ˜•

์ „์ฒด ๊ธ€ 401

[๋งˆ์ผ€ํŒ…์„ ์œ„ํ•œ ๋ฐ์ดํ„ฐ๋ถ„์„2] ํด๋Ÿฌ์Šคํ„ฐ๋ง์„ ํ™œ์šฉํ•œ ์„ธ๋ถ„ํ™”

ํด๋Ÿฌ์Šคํ„ฐ๋ง(Clustering)์€ ๋ฐ์ดํ„ฐ์—์„œ ํ‘œ๋ฉด์ƒ์œผ๋กœ๋Š” ์•ˆ ๋ณด์ด๋Š” ํŒจํ„ด์„ ์ฐพ์„ ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ค€๋‹ค. ์ค‘์š”ํ•œ ๊ฒƒ์€ ๋ช‡ ๊ฐœ์˜ ํด๋Ÿฌ์Šคํ„ฐ๊ฐ€ ์ƒˆ๋ถ„ํ™”๋ฅผ ์ž˜ ํ•ด๋‚ด๋Š”์ง€ ์ฐพ์•„๋‚ด๋Š” ๊ฒƒ์ด๋‹ค. ํด๋Ÿฌ์Šคํ„ฐ๋ง์˜ ๋Œ€ํ‘œ์ ์ธ ๋ฐฉ๋ฒ•์€ k-means clustering ์ด ์žˆ๋‹ค. k-means clustering - group similar data points - iterative approach (๋ฐ˜๋ณต์ ์ธ ์ ‘๊ทผ๋ฒ•) - Starting point : Randomly selected cluster centers , Variable = you're interested in (location, demographics,,,) ----> revaluate hoe good your random choice was and improve it! ๊ณผ์ • 1..

[๋งˆ์ผ€ํŒ…์„ ์œ„ํ•œ ๋ฐ์ดํ„ฐ๋ถ„์„1] ๋งˆ์ผ€ํŒ…์—์„œ์˜ ์„ธ๋ถ„ํ™”

*๋งˆ์ผ€ํŒ…์„ ์œ„ํ•œ ๋ฐ์ดํ„ฐ ๋ถ„์„ ๋ฐฉ๋ฒ•๋ก ์— ๋Œ€ํ•ด ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์„ ์ •๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค. ์„ธ๋ถ„ํ™” segmentation - ๊ณตํ†ต๋œ ํŠน์„ฑ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์‚ฌ๋žŒ๋“ค์„ ๊ทธ๋ฃน๋ณ„๋กœ ๋ถ„๋ฅ˜ํ•˜๋Š” ๊ฒƒ - ํ”Œ๋žซํผ(ํŽ˜์ด์Šค๋ถ, ๊ตฌ๊ธ€,,,,)์—์„œ ํƒ€์ผ“ํŒ…ํ•˜๋Š”๋ฐ์— ์“ฐ์ผ ์ˆ˜ ์žˆ๋‹ค - ํƒ€๊ฒŸํŒ… ์ „์— ์„ธ๋ถ„ํ™” ๋จผ์ € ์ˆ˜ํ–‰ํ•ด์•ผ ํ•œ๋‹ค. ์„ธ๋ถ„ํ™”๋Š” 2๊ฐ€์ง€ ํ˜•ํƒœ๋กœ ๋‚˜ํƒ€๋‚œ๋‹ค. 1. developed from a persona - ๊ทธ ์‚ฌ๋žŒ์˜ ๊ตฌ์„ฑ์š”์†Œ์— ๋”ฐ๋ผ ๋ถ„๋ฅ˜ (๋‚˜์ด,์ง์—… ๋“ฑ) 2. developed from data analytics - k-means clustering, statistical analysis,,, ์„ธ๋ถ„ํ™”๋ฅผ ํ•˜๋Š” ์ด์œ ? - ์„ธ๋ถ„ํ™” helps us reach the right users! ์„ธ๋ถ„ํ™”์˜ ๋ณ€์ˆ˜ : demograpic(์ธ๊ตฌํ†ต๊ณ„ํ•™์ ), psychogr..

[๋จธ์‹ ๋Ÿฌ๋‹4] Logistic Regression ๋กœ์ง€์Šคํ‹ฑ ํšŒ๊ท€ pyhton

binary classification์€ ์ข…๋ฅ˜๊ฐ€ 2๊ฐœ๋กœ ๋‚˜๋‰˜์–ด์ง„ ๋ฐ์ดํ„ฐ๊ฐ€ ์žˆ๊ณ  ์ด๋ฅผ ๋ถ„๋ฅ˜ํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. ์ด ๋ฌธ์ œ๋Š” ์˜ˆ์ธก ๊ฐ’์ด ์—ฐ์†์ ์ธ ๊ฐ’์ด ์•„๋‹Œ 0 ๋˜๋Š” 1์ž…๋‹ˆ๋‹ค. ์˜ˆ์‹œ ์ด๋ฉ”์ผ : ์ŠคํŒธ์ธ๊ฐ€ / ์•„๋‹Œ๊ฐ€? ์˜จ๋ผ์ธ ๊ฑฐ๋ž˜: Fraudulent Financial Statement (FFS)์ธ๊ฐ€ / ์•„๋‹Œ๊ฐ€? ์ข…์–‘ : ์•…์„ฑ์ข…์–‘(์•”)์ธ๊ฐ€ / ์–‘์„ฑ์ธ๊ฐ€? ์ด๋•Œ๋Š” ์šฐ๋ฆฌ์˜ ์˜ˆ์ธก ๊ฐ’์„ ํ™•๋ฅ  ๊ฐ’์œผ๋กœ ๋งŒ๋“  ๋‹ค์Œ์— ํ™•๋ฅ  ๊ฐ’์ด ์šฐ๋ฆฌ์˜ ๊ธฐ์ค€๋ณด๋‹ค ๋†’์œผ๋ฉด 1, ์•„๋‹ˆ๋ฉด 0์œผ๋กœ ๋ถ„๋ฅ˜ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๋ฌธ์ œ๋ฅผ ํ‘ธ๋Š” ๋ฐฉ๋ฒ•์„ logistic regression์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๋‚˜๋ˆ„๋Š” ์ข…๋ฅ˜๊ฐ€ 3๊ฐœ์ด์ƒ์ด๋ฉด - multi classification Logistic regression์„ ์ง„ํ–‰ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ถœ๋ ฅ ๊ฐ’์„ 0๊ณผ 1์˜ ๊ฐ’์œผ๋กœ ๋งž์ถฐ์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ..

[๋จธ์‹ ๋Ÿฌ๋‹3] Multiple Linear Regression ๋‹ค์ค‘์„ ํ˜•ํšŒ๊ท€ python

์‹ค์ œ๋กœ ์˜ˆ์ธก์„ ํ•˜๊ณ ์ž ํ•  ๋–„ ๋ณดํ†ต ํ•˜๋‚˜ ์ด์ƒ์˜ ๋ณ€์ˆ˜๋“ค์„ ๊ณ ๋ คํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. multiple linear regression์€ ๋‹ค์–‘ํ•œ ์ž…๋ ฅ ๋ณ€์ˆ˜๋“ค์„ ์‚ฌ์šฉํ•˜๋Š” ์˜ˆ์ธก๋ชจ๋ธ์ž…๋‹ˆ๋‹ค. ์œ„ ์ด๋ฏธ์ง€๋ฅผ ์˜ˆ๋กœ ์„ค๋ช…ํ•˜๋ฉด, ์ง‘๊ฐ€๊ฒฉ(y)๋ฅผ ์˜ˆ์ธกํ•œ๋‹ค๊ณ  ํ•  ๋•Œ, x1(์นจ์‹ค์ˆ˜), x2=์ธต ์ˆ˜, x3=์ง€์–ด์ง„์—ฐ์ˆ˜, x4=ํฌ๊ธฐ 4๊ฐ€์ง€ feature(n=4)๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค . feature= dimension=attribute x(2)๋Š” =[3 2 40 127](์—ด๋ฒกํ„ฐ๋กœ)๊ฐ€ ๋˜๊ณ , x3(2)๋Š” 30 ์ž…๋‹ˆ๋‹ค default๋Š” ํ•œ์ƒ ์—ด๋ฒกํ„ฐ์ด๊ณ , row vector ์ฆ‰ [3 2 40 127]๋กœ ํ‘œํ˜„ํ•˜๊ณ  ์‹ถ๋‹คํ•˜๋ฉด, transpose๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ‘œํ˜„ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ์ธก ๋ชจ๋ธ ์‹์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์„ธํƒ€0,1,2,3์€ ๊ฐ ๋ณ€์ˆ˜์˜ ๊ฐ€์ค‘์น˜์ด๊ณ , x1,2,3๋Š” ๊ฐ fea..

[๋จธ์‹ ๋Ÿฌ๋‹2] Polynomial Regression python

์ง‘ ์‚ฌ์ด์ฆˆ์— ๋”ฐ๋ฅธ ๊ฐ€๊ฒฉ์„ ์˜ˆ์ธกํ•˜๋Š” One Variable Regression์„ ์ƒ๊ฐํ•ด๋ณด์ž. ๋ฐ์ดํ„ฐ์˜ ๋ถ„ํฌ๋ฅผ ๋ณด๋ฉด, ์˜ˆ์ธกํ•˜๋ ค๋Š” ์ง์„ ๊ฐ’์ด ์•ˆ ๋‚˜ํƒ€๋‚  ์ˆ˜๋„ ์žˆ๋‹ค. (์‚ฌ์ด์ฆˆ์™€ ๊ฐ€๊ฒฉ์ด ๋น„๋ก€ํ•˜์ง€ ์•Š์Œ) ์ด๋•Œ, ๋ณ€์ˆ˜๊ฐ’์„ ๊ทธ๋Œ€๋กœ ๊ณฑํ•˜๋Š”๊ฒƒ์ด ์•„๋‹Œ ๋ฃจํŠธx๋‚˜ x์˜ ๊ฑฐ๋“ญ์ œ๊ณฑ, sinx ๋“ฑ x๋ฅผ ๋ณ€ํ™˜ํ•œ ๊ฐ’์„ ์ƒˆ๋กœ์šด ์นผ๋Ÿผ์œผ๋กœ ์ถ”๊ฐ€ํ•˜์—ฌ ์˜ˆ์ธก๋ชจ๋ธ์„ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๋ฅผ ๋‹ค์ค‘ํšŒ๊ท€ํ•˜๋ฉด ๋œ๋‹ค.(lost function, gradient descent ์ˆ˜ํ–‰ํ•˜๋ฉด ๋จ) ํŒŒ์ด์ฌ์—์„œ ์‚ฌ์ดํ‚ท๋Ÿฐ์˜ PolynomialFeatures๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. from sklearn.preprocessing import PolynomialFeatures https://scikit-learn.org/stable/modules/generated/sklearn.p..

[kaggle competition1]Store Sales - Time Series Forecasting Use machine learning to predict grocery sales 1-๋ณ€์ˆ˜์„ค๋ช…

https://www.kaggle.com/competitions/store-sales-time-series-forecasting Store Sales - Time Series Forecasting | Kaggle www.kaggle.com ๋Œ€ํšŒ ๊ฐœ์š” - ์—์ฝฐ๋„๋ฅด์— ์œ„์น˜ํ•œ Favorita ๋งค์žฅ์—์„œ ํŒ๋งค๋˜๋Š” ์ˆ˜์ฒœ ๊ฐœ์˜ ์ œํ’ˆ๊ตฐ์˜ ๋งค์ถœ์„ ์˜ˆ์ธก ๋ฐ์ดํ„ฐ ์…‹,๋ณ€์ˆ˜ ์„ค๋ช… 1. train.csv - store_nbr : ์ œํ’ˆ์ด ํŒ๋งค๋˜๋Š” ์Šคํ† ์–ด id family : ํŒ๋งค๋˜๋Š” ์ œํ’ˆ์˜ ์ข…๋ฅ˜ ๋”๋ณด๊ธฐ ( ['AUTOMOTIVE', 'BABY CARE', 'BEAUTY', 'BEVERAGES', 'BOOKS', 'BREAD/BAKERY', 'CELEBRATION', 'CLEANING', 'DAIRY', 'DELI', 'EGGS',..

[๋จธ์‹ ๋Ÿฌ๋‹1] ์„ ํ˜•ํšŒ๊ท€ Linear Regression , gradient descent pyhton

๊ณผ๊ฑฐ ๋ฐ์ดํ„ฐ ๊ธฐ๋ฐ˜์œผ๋กœ, ์ž…๋ ฅ ์ฃผ์–ด์กŒ์„ ๋•Œ ์ถœ๋ ฅ(์˜ˆ์ธก๊ฐ’)์ด ๋‚˜์™€์•ผ ํ•œ๋‹ค. ์˜ˆ์ธกํ•˜๊ณ ์ž ํ•˜๋Š” ๋ณ€์ˆ˜ = target variable(ํƒ€๊ฒŸ ๋ณ€์ˆ˜) ํƒ€๊ฒŸ ๋ณ€์ˆ˜๊ฐ€ ์‹ค์ˆ˜์ด๋ฉด = regression problem, ํƒ€๊ฒŸ ๋ณ€์ˆ˜๊ฐ€ ์นดํ…Œ๊ณ ๋ฆฌ ๋ณ€์ˆ˜์ด๋ฉด = classification (๋Œ€ํ‘œ์ ์ธ ๋ฐฉ๋ฒ•๋ก : ๋กœ์ง€์Šคํ‹ฑ ํšŒ๊ท€) ์ด ๋‘˜์€ supervised learning(์ง€๋„ ํ•™์Šต)์ด๋‹ค. unsupervised learning(๋น„์ง€๋„ ํ•™์Šต)์—๋Š” clustring(k-means) ๋“ฑ์ด ์žˆ๋‹ค. ์„ ํ˜•ํšŒ๊ท€ Linear Regression - ์ข…์† ๋ณ€์ˆ˜ ๐‘ฆ์™€ ํ•œ๊ฐœ ์ด์ƒ์˜ ๋…๋ฆฝ ๋ณ€์ˆ˜ ๐‘‹์™€์˜ ์„ ํ˜• ๊ด€๊ณ„๋ฅผ ๋ชจ๋ธ๋ง(=1์ฐจ๋กœ ์ด๋ฃจ์–ด์ง„ ์ง์„ ์„ ๊ตฌํ•œ๋‹ค)ํ•˜๋Š” ๋ฐฉ๋ฒ•๋ก  - ์ตœ์ ์˜ ์ง์„ ์„ ์ฐพ์•„ ๋…๋ฆฝ ๋ณ€์ˆ˜์™€ ์ข…์† ๋ณ€์ˆ˜ ์‚ฌ์ด์˜ ๊ด€๊ณ„๋ฅผ ๋„์ถœํ•˜๋Š” ๊ณผ์ • ๋…๋ฆฝ ๋ณ€์ˆ˜= ์ž…๋ ฅ ๊ฐ’..

[์„ ํ˜•๋Œ€์ˆ˜ํ•™] ๊ธฐ์ €๋ฒกํ„ฐ ๋œป

์„ ํ˜•๋Œ€์ˆ˜ํ•™์„ ๊ณต๋ถ€ํ•˜๋ฉด์„œ ์ฒซ๋ฒˆ์จฐ ๊ณ ๋น„๊ฐ€ ๊ธฐ์ € ๋ฒกํ„ฐ์—์„œ ์ฐพ์•„์™€ ๋ฒ„๋ ธ๋‹ค. ์„ค๋ช…์„ ์ฐพ์•„๋ด๋„ ๋„ˆ๋ฌด ์–ด๋ ค์›Œ์„œ ์ดํ•ด๋ฅผ ๋ชปํ–ˆ์—ˆ๋‹ค. ์™„๋ฒฝํ•˜๊ฒŒ 100% ์•ˆ๋‹ค๊ณ ๋Š” ํ•  ์ˆ˜ ์—†์ง€๋งŒ ๊ทธ๋ž˜๋„ ์—ฌํƒœ๊นŒ์ง€ ์ดํ•ดํ•œ ๋‚ด์šฉ์„ ๋ฐ”ํƒ•์œผ๋กœ ๊ธฐ์ € ๋ฒกํ„ฐ์— ๋Œ€ํ•œ ์„ค๋ช…์„ ํ•ด๋ณด๊ฒ ๋‹ค. ๊ธฐ์ € ๋ฒกํ„ฐ๋ž€ ์–ด๋–ค ๊ณต๊ฐ„์„ ์ด๋ฃจ๋Š” ์›์†Œ ์ค‘ ๊ฐ€์žฅ ์—‘๊ธฐ์Šค์ธ ์›์†Œ์ด๋‹ค. ์ด๋•Œ, ์–ด๋–ค ๊ณต๊ฐ„์€ ๋Œ€๋ถ€๋ถ„ ์ขŒํ‘œํ‰๋ฉด์œผ๋กœ ๋งŽ์ด ์„ค๋ช…ํ•˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์–ด๋–ค ๊ณต๊ฐ„์ด x์ถ•, y์ถ•์œผ๋กœ ์ด๋ฃจ์–ด์ง„ ์ขŒํ‘œํ‰๋ฉด(R^2)์ด๋ฉด, {(1,0),(0,1)}์€ ๊ธฐ์ € ๋ฒกํ„ฐ์ด๋‹ค. ์ด ๋‘ ์ขŒํ‘œ์— ์–ด๋–ค ์‹ค์ˆ˜๋ฅผ ๊ณฑํ•˜๋ฉด, ์ฆ‰ ๋ฒกํ„ฐ ์กฐํ•ฉ์œผ๋กœ ์ขŒํ‘œํ‰๋ฉด์— ์žˆ๋Š” ๋ชจ๋“  ์ ์„ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ {(1,0),(2,0)}์€ ๊ธฐ์ œ๊ฐ€ ๋  ์ˆ˜ ์—†๋‹ค. ์•„๋ฌด๋ฆฌ ํฐ ์ˆ˜๋ฅผ ๊ณฑํ•ด๋„, x์ถ• ์œ„์—์„œ๋งŒ ์ ์ด ์ฐํžˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ชจ๋“  ์ขŒํ‘œํ‰๋ฉด..

[python] packing & unpacking ๋ฆฌ์ŠคํŠธ, ํŠœํ”Œ

ํŠœํ”Œ ์–ธํŒจํ‚น ์˜ˆ์‹œ - ๋ฆฌ์ŠคํŠธ๋Š” ()๋ฅผ []๋กœ ๋ฐ”๊ฟ”์ฃผ๋ฉด ๋ฆฌ์ŠคํŠธ ํŒจํ‚น, ์–ธํŒจํ‚น์ด ๊ฐ€๋Šฅํ•˜๋‹ค. a, b = (1, 10) print(a) print(b) 1 10 a, *b, c = (1, 2, 3, 4, 5) print(a) print(b) print(c) 1 [2,3,4] 5 *์€ ๋‚˜๋จธ์ง€๋ฅผ ๋ฌถ์–ด์ค€๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋ฉด ํŽธํ•˜๋‹ค.

[python] ์‚ผํ•ญ์—ฐ์‚ฐ์ž(Ternary operators) - ์กฐ๊ฑด๋ฌธ

value1 if condition else value2 condition์ด ์ฐธ์ด๋ฉด value1, ๊ฑฐ์ง“์ด๋ฉด value2๋ฅผ ๋ฐ˜ํ™˜. if ์™€ else๋กœ ๋‚˜๋‰˜๋Š” ์กฐ๊ฑด๋ฌธ์—์„œ ์‚ฌ์šฉ ๊ฐ€๋Šฅ! ์˜ˆ์‹œ value = 10 "odd" if value%2 else "even" ๊ฒฐ๊ณผ "even"

[python] ํŒŒ์ด์ฌ ๋‚ด์žฅํ•จ์ˆ˜ ๋ชฉ๋ก

https://docs.python.org/ko/3/library/functions.html ๋‚ด์žฅ ํ•จ์ˆ˜ — Python 3.11.0 ๋ฌธ์„œ ๋‚ด์žฅ ํ•จ์ˆ˜ ํŒŒ์ด์ฌ ์ธํ„ฐํ”„๋ฆฌํ„ฐ์—๋Š” ํ•ญ์ƒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋งŽ์€ ํ•จ์ˆ˜์™€ ํ˜•์ด ๋‚ด์žฅ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์—์„œ ์•ŒํŒŒ๋ฒณ ์ˆœ์œผ๋กœ ๋‚˜์—ดํ•ฉ๋‹ˆ๋‹ค. abs(x, /) ์ˆซ์ž์˜ ์ ˆ๋Œ“๊ฐ’์„ ๋Œ๋ ค์ค๋‹ˆ๋‹ค. ์ธ์ž๋Š” ์ •์ˆ˜, ์‹ค์ˆ˜ ๋˜๋Š” docs.python.org

[python ์ž๋ฃŒ๊ตฌ์กฐ] ์ง‘ํ•ฉ set

- ๋”•์…”๋„ˆ๋ฆฌ์˜ ํ‚ค๋งŒ ๋ชจ์—ฌ์žˆ๋Š” ํ˜•ํƒœ ๋นˆ ์ง‘ํ•ฉ ์„ ์–ธ s = set() s=set([1,2,3,'set']) print(s) s.add(4) s.add('set') print(s)#์ค‘๋ณตx s.remove(2) #s.remove(99)#์—๋Ÿฌ๋ฐœ์ƒ s.discard(99)#์—๋Ÿฌ ๋ฌด์‹œ print(s) s.update([3,99,True,None]) print(s) s.clear() print(s) result {1, 2, 3, 'set'} {1, 2, 3, 4, 'set'} {1, 3, 4, 'set'} {None, 1, 3, 4, 99, 'set'} set() ํ•ฉ์ง‘ํ•ฉ, ๊ต์ง‘ํ•ฉ, ์ฐจ์ง‘ํ•ฉ, ๋ฐฐํƒ€์  ํ•ฉ์ง‘ํ•ฉ ์—ฐ์‚ฐ ๊ฐ€๋Šฅ s1 &s2 s1 | s2 s1 - s2 s1 ^ s2

[python ์ž๋ฃŒ๊ตฌ์กฐ] ๋”•์…”๋„ˆ๋ฆฌ dictionary

- ๋งคํ•‘ํ•˜๊ธฐ ์œ„ํ•จ - key์™€ value๋กœ ์ด๋ฃจ์–ด์ง {key1: Value1,key2:Value2,,,} key์—๋Š” hashableํ•œ ๊ฒƒ๋“ค์„ ๋„ฃ์„ ์ˆ˜ ์žˆ์Œ value๋Š” ์ œํ•œ์ด ์—†์Œ ๋นˆ ๋”•์…”๋„ˆ๋ฆฌ ์„ ์–ธ dict={} ์‹คํ–‰ ์˜ˆ์‹œ dictionary={} dictionary['first']=1 dictionary['tuple']=(1,2,3) dictionary[(4,'tuple')]=1.5 print(dictionary) ###{'first': 1, 'tuple': (1, 2, 3), (4, 'tuple'): 1.5} print(dictionary['tuple'])#(1, 2, 3) print(dictionary[4,'tuple'])#1.5 dictionary['first']='one' #์ค‘๋ณต์€ ๋ฎ์–ด์”Œ์›Œ์ง p..

[python] ํŒŒ์ด์ฌ ํŠน์ง•๊ณผ ์žฅ์ 

1. ์ธํ„ฐํ”„๋ฆฌํ„ฐ ์–ธ์–ด์ด๋‹ค. - ์ธํ„ฐํ”„๋ฆฌํ„ฐ๋Š” ์ปดํŒŒ์ผ๊ณผ ๋Œ€๋น„๋˜๋Š” ๊ฐœ๋…์œผ๋กœ, ์ฝ”๋“œ ํŒŒ์ผ(.py)๋ฅผ ์ปดํ“จํ„ฐ์— ์ž‘๋™ํ•˜๊ฒŒ๋” ๋„ฃ์„ ๋•Œ ์ปดํ“จํ„ฐ ์–ธ์–ด์ธ 0๊ณผ 1๋กœ ๋ณ€ํ™˜ํ•ด์•ผํ•œ๋‹ค. ์ด ๊ณผ์ •์—์„œ ์“ฐ๋Š” ๋‘๊ฐ€์ง€ ๋ฐฉ๋ฒ•์ด ์ปดํŒŒ์ผ๊ณผ ์ธํ„ฐํ”„๋ฆฌํ„ฐ์ด๋‹ค. ๋Œ€ํ‘œ์ ์ธ ์ปดํŒŒ์ผ ์–ธ์–ด๋Š” C์ด๊ณ , ์ธํ„ฐํ”„๋ฆฌํ„ฐ์–ธ์–ด๋Š” python, js ๋“ฑ์ด ์žˆ๋‹ค. ์ปดํŒŒ์ผ ์–ธ์–ด๋Š” ๊ณ ๋Œ€๋กœ ์“ฐ๋ฉด ๋˜์ง€๋งŒ, ์ธํ„ฐํ”„๋ฆฌํ„ฐ์–ธ์–ด๋Š” ์ฝ”๋“œ์™€ ์ธํ„ฐํ”„๋ฆฌํ„ฐ๊ฐ€ ์žˆ์–ด์•ผ ํ•œ๋‹ค. 2. ์™„์ „ ๊ฐ์ฒด ์ง€ํ–ฅ ์–ธ์–ด์ด๋‹ค. int,, float,,, ๋“ฑ๋“ฑ ๋ชจ๋‘๊ฐ€ ๊ฐ์ฒด์ด๋‹ค. 3. ๋™์  ํƒ€์ดํ•‘ ์–ธ์–ด์ด๋‹ค. - ์ž๋ฐ”์˜ ๊ฒฝ์šฐ ๋ณ€์ˆ˜๋งˆ๋‹ค ์ž๋ฃŒํ˜•์„ ๋ช…์‹œํ•ด์•ผํ•˜์ง€๋งŒ, ํŒŒ์ด์ฌ์€ a=3์ด๋ผ๊ณ  ์ž…๋ ฅํ•ด๋„ ์ž๋™์œผ๋กœ int๋กœ ์ธ์‹ํ•œ๋‹ค. 4. ์‰ฌ์šด ๋ฌธ๋ฒ•๊ณผ ๋‹ค์–‘ํ•œ ๊ธฐ๋Šฅ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค. 5. ๋‹ค์–‘ํ•œ ๊ณณ์—์„œ ๋„๋ฆฌ ์“ฐ์ธ๋‹ค. 6. ๋ฐ์ดํ„ฐ ๊ฐ€๊ณต์—์„œ ๋‘๊ฐ์„..

ํž™ heap, max heap, min heap ๊ฐœ๋…

ํž™์€ ์ด์ง„ํŠธ๋ฆฌ์˜ ํ•œ ์ข…๋ฅ˜๋กœ, ๊ฐ’์ด ์ตœ๋Œ€ ํ˜น์€ ์ตœ์†Œ ๋…ธ๋“œ์— ๋น ๋ฅด๊ฒŒ ์ ‘๊ทผํ•ด์•ผ ํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค. ํž™ ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ์„ค๊ณ„ํ•˜๋Š” ๋ฐฉ๋ฒ•์—๋Š” 2๊ฐ€์ง€, max heap(์ตœ๋Œ€ํž™)๊ณผ min heap(์ตœ์†Œ ํž™)์ด ์žˆ๋‹ค. ์ตœ๋Œ€ํž™์€ ๋ฃจํŠธ ๋…ธ๋“œ๊ฐ€ ํž™์—์„œ ๊ฐ€์žฅ ํฌ๊ณ , ๋…ธ๋“œ์˜ ๊ฐ ๊ฐ’์€ ๋ถ€๋ชจ๋…ธ๋“œ๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™๋‹ค ์ตœ์†Œํž™์€ ๋ฃจํŠธ ๋…ธ๋“œ๊ฐ€ ํž™์—์„œ ๊ฐ€์žฅ ์ž‘๊ณ , ๋…ธ๋“œ์˜ ๊ฐ ๊ฐ’์€ ๋ถ€๋ชจ๋…ธ๋“œ๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™๋‹ค

์ด์ง„ํƒ์ƒ‰ํŠธ๋ฆฌ

์ด์ง„ํŠธ๋ฆฌ - ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉ๋˜๋Š” ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ, ๊ฐ ๋ถ€๋ชจ๋…ธ๋“œ๊ฐ€ ํ•ญ์ƒ ์ตœ๋Œ€ 2๊ฐœ์˜ ์ž์‹๋…ธ๋“œ์™€ ๋ถ™์–ด ์žˆ์Œ ์ด์ง„ ํƒ์ƒ‰ ํŠธ๋ฆฌ : ์ด์ง„ ํŠธ๋ฆฌ์˜ ๊ฐ€์žฅ ์ผ๋ฐ˜์ ์ธ ์œ ํ˜•, ๋…ธ๋“œ์˜ key ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌํ•œ ์ƒํƒœ - ์ •๋ ฌ ๊ธฐ์ค€ 1. ๋…ธ๋“œ์˜ ์™ผ์ชฝ ์„œ๋ธŒํŠธ๋ฆฌ์—๋Š” ๋…ธ๋“œ์˜ ํ‚ค๋ณด๋‹ค ์ž‘์€ ํ‚ค๋ฅผ ๊ฐ€์ง„ ๋…ธ๋“œ๋งŒ! 2. ๋…ธ๋“œ์˜ ์˜ค๋ฅธ์ชฝ ์„œ๋ธŒํŠธ๋ฆฌ๋Š” ๋…ธ๋“œ์˜ ํ‚ค๋ณด๋‹ค ํฐ ํ‚ค๋ฅผ ๊ฐ€์ง„ ๋…ธ๋“œ๋งŒ! 3. ์ขŒ์šฐ ์„œ๋ธŒ ํŠธ๋ฆฌ๋„ ๊ฐ๊ฐ ์ด์ง„ ํƒ์ƒ‰ ํŠธ๋ฆฌ 4. ๊ฐ ๋…ธ๋“œ์— ์ค‘๋ณต ํ‚ค(key)๋Š” ์—†์Œ! ๊ทธ๋ž˜์„œ.. ๊ฐ€์žฅ ํฐ ํ‚ค๋ฅผ ๊ฐ€์ง„ ๋…ธ๋“œ๋Š” ๊ฐ€์žฅ ์˜ค๋ฅธ์ชฝ ์„œ๋ธŒํŠธ๋ฆฌ ๋ง๋‹จ(80) ๊ฐ€์žฅ ์ž‘์€ ํ‚ค๋ฅผ ๊ฐ€์ง„ ๋…ธ๋“œ๋Š” ๊ฐ€์žฅ ์™ผ์ชฝ ์„œ๋ธŒํŠธ๋ฆฌ ๋ง๋‹จ(1) ์ด์ง„ํƒ์ƒ‰ํŠธ๋ฆฌ๋กœ ํ•  ์ˆ˜ ์žˆ๋Š” ๋™์ž‘์€ 1. ํŠธ๋ฆฌ์— ๋…ธ๋“œ ์ถ”๊ฐ€ 2. ๋…ธ๋“œ ์‚ญ์ œ 3. ๋…ธํŠธ ์„ ํƒํ•ด ํƒ์ƒ‰ํ•˜๋Š” ํ‚ค๊ฐ€ ์กด์žฌํ•˜๋Š”์ง€ ํ™•์ธ

์„ ํ˜• ์ž๋ฃŒ๊ตฌ์กฐ์™€ ๋น„์„ ํ˜• ์ž๋ฃŒ๊ตฌ์กฐ์˜ ์ฐจ์ด (Linear, NonLinear data structure)

์ž๋ฃŒ๊ตฌ์กฐ๋Š” ์„ ํ˜• ์ž๋ฃŒ๊ตฌ์กฐ์™€ ๋น„์„ ํ˜• ์ž๋ฃŒ๊ตฌ์กฐ๋กœ ๋‚˜๋‰œ๋‹ค. ์„ ํ˜•์ž๋ฃŒ๊ตฌ์กฐ์™€ ๋น„์„ ํ˜• ์ž๋ฃŒ๊ตฌ์กฐ๋Š” ๋ฌด์—‡์ผ๊นŒ? ์„ ํ˜• ์ž๋ฃŒ๊ตฌ์กฐ๋ž€ ํ•˜๋‚˜์˜ ์ž๋ฃŒ ๋’ค์— ํ•˜๋‚˜์˜ ์ž๋ฃŒ๊ฐ€ ์กด์žฌ,์ฆ‰ ์ˆœ์ฐจ์ ์œผ๋กœ ์ด์–ด์ง„ ํ˜•ํƒœ๋ฅผ ์ƒ๊ฐํ•˜๋ฉด ๋œ๋‹ค. 1:1์˜ ์„ ํ˜•๊ด€๊ณ„๋ฅผ ์ด๋ฃจ๊ณ  ์žˆ๋‹ค ๋น„์„ ํ˜• ์ž๋ฃŒ๊ตฌ์กฐ๋ž€ ํ•˜๋‚˜/์—ฌ๋Ÿฌ ๊ฐœ์˜ ์ž๋ฃŒ ๋’ค์— ์—ฌ๋Ÿฌ ๊ฐœ์˜ ์ž๋ฃŒ๊ฐ€ ์กด์žฌํ•˜๋Š” ํ˜•ํƒœ๋กœ, 1:n, ๋˜๋Š” n:n ์˜ ๊ด€๊ณ„๋ฅผ ์ƒ๊ฐํ•˜๋ฉด ๋œ๋‹ค.(์ฃผ๋กœ ๊ณ„์ธต ํ˜•ํƒœ)

[NLP 1-2] BERT : Pre-training of Deep Bidirectional Transformers for Language Understanding ๋…ผ๋ฌธ๋ฆฌ๋ทฐ - 3

#์Šค์Šค๋กœ ๊ณต๋ถ€ํ•˜๊ณ  ๋งŒ๋“  ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค. BERT : Pre-training of Deep Bidirectional Transformers for Language Understanding https://arxiv.org/abs/1810.04805 (์›๋ฌธ) ์ด์ „ ๊ธ€๊ณผ ์ด์–ด์ง€๋Š” ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค. - Introduction & Related Works - Pre-training - Fine-tuning - Experiment - Conclusion + koBERT fine-tuning์€ ์‚ฌ์ „ํ•™์Šต๋œ ๋ฌธ์žฅ์˜ ๋ฌธ๋งฅ ์ •๋ณด ๋“ฑ์„ ๊ณ ๋ คํ•œ weight ๊ฐ’์„ ๊ฐ€์ง€๊ณ , ์‚ฌ์ „ํ›ˆ๋ จ๋œ BERT์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๊ทธ๋Œ€๋กœ ๊ฐ€์ ธ์™€ ๋ฌธ์„œ๋ถ„๋ฅ˜, ๊ฐœ์ฒด๋ช…์ธ์‹๊ณผ ๊ฐ™์€ ๊ณผ์ œ์— ์ ์šฉ ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋ชจ๋ธ์„ ์—…๋ฐ์ดํŠธํ•˜๋Š” ๊ณผ์ •์ž…๋‹ˆ๋‹ค. fine-tuning์€ pre-tr..

[NLP 1-1] BERT : Pre-training of Deep Bidirectional Transformers for Language Understanding ๋…ผ๋ฌธ๋ฆฌ๋ทฐ-2

#์Šค์Šค๋กœ ๊ณต๋ถ€ํ•˜๊ณ  ๋งŒ๋“  ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค. BERT : Pre-training of Deep Bidirectional Transformers for Language Understanding https://arxiv.org/abs/1810.04805 (์›๋ฌธ) ์ด์ „ ๊ธ€๊ณผ ์ด์–ด์ง€๋Š” ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค. - Introduction & Related Works - Pre-training - Fine-tuning - Experiment - Conclusion + koBert BERT๋Š” ๋ฌธ๋งฅ์„ ๋ฐ˜์˜ํ•œ ์ž„๋ฒ ๋”ฉ(Conatextual Embedding)์„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•ด์ฃผ๋Š” ๋ฒ”์šฉ ์–ธ์–ด ํ‘œํ˜„ ๋ชจ๋ธ์ž…๋‹ˆ๋‹ค. BERT๋Š” ํฌ๊ฒŒ pre-training(์‚ฌ์ „ ํ•™์Šต), fine-tuning(๋ฏธ์„ธ ์กฐ์ •) ๋‘ ๋‹จ๊ณ„๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Pre-training..

[NLP 1] BERT : Pre-training of Deep Bidirectional Transformers for Language Understanding ๋…ผ๋ฌธ ๋ฆฌ๋ทฐ - Introduction & Related Works

#์Šค์Šค๋กœ ๊ณต๋ถ€ํ•˜๊ณ  ๋งŒ๋“  ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค. BERT : Pre-training of Deep Bidirectional Transformers for Language Understanding https://arxiv.org/abs/1810.04805 (์›๋ฌธ) ์ž์—ฐ์–ด์ฒ˜๋ฆฌ์—์„œ ๊ฐ€์žฅ ๊ธฐ๋ณธ์ด ๋˜๊ณ  ์ค‘์š”ํ•œ ๋…ผ๋ฌธ ์ค‘ ํ•˜๋‚˜์ธ ๋ฒ„ํŠธ ๋…ผ๋ฌธ์ž…๋‹ˆ๋‹ค. ์›๋ฌธ์„ ๋ฐ”ํƒ•์œผ๋กœ ์„ค๋ช…ํ•˜์˜€์œผ๋ฉฐ, ์ดํ•ด๋ฅผ ๋•๊ธฐ ์œ„ํ•œ ๋ช‡ ๊ฐ€์ง€ ํ•œ๊ตญ์–ด ์˜ˆ์‹œ๋ฅผ ๋ฆฌ์„œ์น˜ํ•˜์—ฌ ๋„ฃ์—ˆ์Šต๋‹ˆ๋‹ค! ์•„๋งˆ 5๋ถ€๋ถ„์œผ๋กœ ๋‚˜๋ˆ„์–ด ์„ค๋ช…ํ•  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค! - Introduction & Related Works - Pre-training - Fine-tuning - Experiment - Conclusion + koBert BERT๋Š” ๊ตฌ๊ธ€์—์„œ ๊ฐœ๋ฐœํ•œ NLP ์‚ฌ์ „ ํ›ˆ๋ จ ๋ชจ๋ธ๋กœ, ํŠน์ • ๋ถ„์•ผ์— ๊ตญํ•œ๋œ ๊ธฐ์ˆ ์ด..

๋ฐ˜์‘ํ˜•