Notice
Recent Posts
Recent Comments
ยซ   2024/11   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
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
Archives
Today
In Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

A Joyful AI Research Journey๐ŸŒณ๐Ÿ˜Š

[3] 241101 Python [Goorm All-In-One Pass! AI Project Master 4๊ธฐ 3์ผ] ๋ณธ๋ฌธ

๐ŸŒณAI Project Mastery Bootcamp 2024โœจ/Revision

[3] 241101 Python [Goorm All-In-One Pass! AI Project Master 4๊ธฐ 3์ผ]

yjyuwisely 2024. 11. 1. 09:11

241101 Fri 3rd class

์˜ค๋Š˜ ๋ฐฐ์šด ๊ฒƒ ์ค‘ ๊ธฐ์–ตํ•  ๊ฒƒ์„ ์ •๋ฆฌํ–ˆ๋‹ค.

*๋ณต์Šตํ•˜๊ธฐ
https://wikidocs.net/11

 

02์žฅ ํŒŒ์ด์ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์˜ ๊ธฐ์ดˆ, ์ž๋ฃŒํ˜•

‘์–ด๋–ค ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์ด๋“  ๊ทธ ์–ธ์–ด์˜ ์ž๋ฃŒํ˜•์„ ์•Œ๊ณ  ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋‹ค๋ฉด ์ด๋ฏธ ๊ทธ ์–ธ์–ด์˜ ์ ˆ๋ฐ˜์„ ํ„ฐ๋“ํ•œ ๊ฒƒ์ด๋‚˜ ๋‹ค๋ฆ„์—†๋‹ค’๋ผ๋Š” ๋ง์ด ์žˆ๋‹ค. ์ž๋ฃŒํ˜•์ด๋ž€ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ํ•  ๋•Œ ์“ฐ์ด๋Š” ์ˆซ์ž,…

wikidocs.net


๋ชฐ๋ž๋˜ ๊ฒƒ

ํŒ๋‹ค์Šค(Pandas)์—์„œ ์ฃผ์š” ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ๋Š” **๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„(DataFrame)**๊ณผ **์‹œ๋ฆฌ์ฆˆ(Series)**์ž…๋‹ˆ๋‹ค.

  • ๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„(DataFrame): 2์ฐจ์› ํ…Œ์ด๋ธ” ํ˜•ํƒœ์˜ ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ๋กœ, ํ–‰๊ณผ ์—ด๋กœ ๊ตฌ์„ฑ๋ฉ๋‹ˆ๋‹ค. ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ ํƒ€์ž…์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๊ณ , ์—‘์…€์ฒ˜๋Ÿผ ๋ฐ์ดํ„ฐ๋ฅผ ํ•„ํ„ฐ๋ง, ๊ทธ๋ฃนํ™”, ์ •๋ ฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์‹œ๋ฆฌ์ฆˆ(Series): 1์ฐจ์› ๋ฐฐ์—ด ํ˜•ํƒœ์˜ ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ๋กœ, ํ•˜๋‚˜์˜ ๋ฐ์ดํ„ฐ ์œ ํ˜•๋งŒ ๊ฐ€์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ธ๋ฑ์Šค์™€ ๊ฐ’์œผ๋กœ ๊ตฌ์„ฑ๋˜๋ฉฐ, ๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„์˜ ํŠน์ • ์—ด์„ ์‹œ๋ฆฌ์ฆˆ๋กœ ๋‹ค๋ฃฐ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„์€ ์—ฌ๋Ÿฌ ๊ฐœ์˜ ์‹œ๋ฆฌ์ฆˆ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์œผ๋ฉฐ, ๋‘˜ ๋‹ค ๋ฐ์ดํ„ฐ ๋ถ„์„์„ ์œ„ํ•œ ๋‹ค์–‘ํ•œ ๋ฉ”์„œ๋“œ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.


GPU 4080
GPU ๊ฒฌ์ ์„œ ๋ฉ”์‹œ์ง€ ๊ฐ€๋Šฅ


 

https://wikidocs.net/4307

 

01-1 ํŒŒ์ด์ฌ์ด๋ž€?

ํŒŒ์ด์ฌ(Python)์€ 1990๋…„ ์•”์Šคํ…Œ๋ฅด๋‹ด์˜ ๊ท€๋„ ๋ฐ˜ ๋กœ์„ฌ(Guido van rossum)์ด ๊ฐœ๋ฐœํ•œ ์ธํ„ฐํ”„๋ฆฌํ„ฐ ์–ธ์–ด์ด๋‹ค. ๊ท€๋„๋Š” ํŒŒ์ด์ฌ์ด๋ผ๋Š” ์ด๋ฆ„์„ ์ž์‹ ์ด ์ข‹์•„ํ•˜๋Š” ์ฝ”๋ฏธ๋”” ์‡ผ์ธ…

wikidocs.net

๊ตฌ๊ธ€์—์„œ ๋”ฅ๋Ÿฌ๋‹์— ์“ด๋‹ค -> ํผ์ง 
๋ฐ์ดํ„ฐ๋ถ„์„ ์œ ๋ฆฌ, ์›น๋ฐ์ดํ„ฐ ์ˆ˜์ง‘, ์›น
์‚ฌ์šฉ์ž๊ฐ€ ๋งŽ์•„์ง 

์ธ๊ณต์ง€๋Šฅ, ๋จธ์‹ ๋Ÿฌ๋‹ 
ํŒŒ์ด์ฌ ์œ„์—์„œ ๊ฐ€์ ธ์™€์„œ ์“ด๋‹ค 

Tensorflow(๊ตฌ๊ธ€) - ๋”ฅ๋Ÿฌ๋‹ <--- 1.x --> 2.x
-> Keras ==> ์ดˆ๋ณด์ž๋ถ„๋“ค๋„ ์ž˜ ์‚ฌ์šฉํ•˜๋„๋ก ์‰ฝ๊ฒŒ ๋งŒ๋“ค์—ˆ๋‹ค, ์„ฑ๋Šฅ ์ค„์–ด๋“ฆ 

Pytorch - ๋”ฅ๋Ÿฌ๋‹
์‹ค๋ฌด 

๋ฐ์ดํ„ฐ ๋ถ„์„ 
Kaggle (์ž˜ ํ•˜๋Š” ์‚ฌ๋žŒ ์ฝ”๋“œ ๋ณด๊ณ  ๋ฐฐ์šด๋‹ค ์ฝ”๋“œ ๊ตฌํ˜„ํ•ด์„œ ์˜ฌ๋ฆผ)
Matplotlib
Seaborn
Plotly

๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ
numpy
pandas


ํ•œ๊ตญ ์˜จ๋ผ์ธ ๊ฐ•์˜: ์‹œ๊ฐ„ ์ฑ„์šฐ๋Š” ๊ฒฝ์šฐ ์žˆ์Œ

AI ์“ฐ๊ณ  ์•ˆ ์“ฐ๊ณ  30-50ํผ ์ฐจ์ด๊ฐ€ ๋‚œ๋‹ค. 

๊ธฐ๋ณธ์ด Python, ์ค‘์š”ํ•˜๋‹ค 

Python์„ ๋ชจ๋ฅด๋ฉด, ๋จธ์‹ ๋Ÿฌ๋‹, ๋”ฅ๋Ÿฌ๋‹ ์ฑ…์„ ๋ณด๊ธฐ ํž˜๋“ฆ, ๋ง‰ํž˜ 

Python, ํ•„์ˆ˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ, ๋”ฅ๋Ÿฌ๋‹์„ ๋ชจ๋ฅด๋Š” ๊ฑด์ง€ 

Python์„ ์•Œ๊ณ  ๋ชจ๋ฅด๋Š” ๊ฑธ ๋ช…ํ™•ํ•˜๊ฒŒ ์•Œ ์ˆ˜ ์žˆ๋‹ค.  


AI ์ด๋ก ๋„ ์ค‘์š”ํ•˜๋‹ค
๋‹จ๊ณ„๊ฐ€ ์˜ฌ๋ผ๊ฐ€๋ฉด ๋…ผ๋ฌธ์„ ๋งŽ์ด ๋ณธ๋‹ค 

๊ธฐ๋ณธ ๋ฉด์ ‘ ์งˆ๋ฌธ 
์—ฐ์Šต ๋งŽ์ด ํ•œ๋‹ค 

Python ์ œ๋Œ€๋กœ ํ•˜๋ฉด ๋‹ค๋ฅธ ์–ธ์–ด๋„ ๋ฒ”์œ„ ๋„“์–ด์ง€๊ฒŒ ๋œ๋‹ค.


Python -> Pandas -> Dataframe ๋‹ค ์—ฐ๊ฒฐ ๋œ๋‹ค. 

๋ชจ๋ฅด๋Š” ๊ฒŒ ๋งŽ์œผ๋ฉด, ์ ์„ฑ ์•„๋‹Œ๊ฐ€ ํ•˜๊ณ  ํฌ๊ธฐํ•˜๊ฒŒ ๋œ๋‹ค (์™œ ๊ทธ๋Ÿฐ์ง€ ๋ชจ๋ฅด๊ณ ) 

์‹ค๋ฌด 1,2,3๋…„ -> ๊ธฐ๋ณธ (ํ† ์˜, ๋…ผ๋ฌธ) ๋ชจ๋ฅด๋ฉด ํž˜๋“ฆ 

knn, ๋”ฅ๋Ÿฌ๋‹ ๋ชจ๋ธ ์งœ๋ณด๊ธฐ 

๋ณต์Šต ๋ช‡ ์‹œ๊ฐ„ 

ML, DL, LLM ์ฑ… 1๊ถŒ ์‚ฌ์„œ ๋ณด๊ธฐ ์ ์–ด๋„ LLM ์ฑ…

๋ณต์Šต์ด ์ค‘์š”ํ•˜๋‹ค 

ํ”„๋กœ์ ํŠธ ์—ด์‹ฌํžˆ ๋งŒ๋“ค๊ธฐ, ์•„์‰ฌ์›€ ๋‚จ๊ธฐ์ง€X


ipynb

์ž๋ฃŒํ˜• ์ค‘์š”ํ•˜๋‹ค 

https://wikidocs.net/13#_9

 

02-2 ๋ฌธ์ž์—ด ์ž๋ฃŒํ˜•

๋ฌธ์ž์—ด(string)์ด๋ž€ ์—ฐ์†๋œ ๋ฌธ์ž๋“ค์˜ ๋‚˜์—ด์„ ๋งํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค. ```plaintext Life is too short, You need Python a…

wikidocs.net

์ธ๋ฑ์‹ฑ(indexing)์ด๋ž€ ๋ฌด์—‡์ธ๊ฐ€๋ฅผ ‘๊ฐ€๋ฆฌํ‚จ๋‹ค’, ์Šฌ๋ผ์ด์‹ฑ(slicing)์€ ๋ฌด์—‡์ธ๊ฐ€๋ฅผ ‘์ž˜๋ผ ๋‚ธ๋‹ค’๋ผ๋Š” ์˜๋ฏธ์ด๋‹ค. 

์ธ๋ฑ์‹ฑ(indexing)์€ ๋ฌธ์ž์—ด์ด๋‚˜ ๋ฆฌ์ŠคํŠธ์˜ ํŠน์ • ์œ„์น˜์— ์žˆ๋Š” ์š”์†Œ๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” ๋ฐฉ๋ฒ•์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ๋ฌธ์ž์—ด a์—์„œ a[3]์€ a์˜ 3๋ฒˆ์งธ ์œ„์น˜์— ์žˆ๋Š” ๋ฌธ์ž๋ฅผ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค. ๋ฐ˜๋ฉด, ์Šฌ๋ผ์ด์‹ฑ(slicing)์€ ๋ฌธ์ž์—ด์ด๋‚˜ ๋ฆฌ์ŠคํŠธ์˜ ํŠน์ • ๋ฒ”์œ„์— ์žˆ๋Š” ์—ฌ๋Ÿฌ ์š”์†Œ๋ฅผ ์ž˜๋ผ๋‚ด์–ด ๊ฐ€์ ธ์˜ค๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, a[1:4]๋Š” ์ธ๋ฑ์Šค 1๋ถ€ํ„ฐ 3๊นŒ์ง€์˜ ๋ฌธ์ž๋“ค์„ ํฌํ•จํ•œ ๋ถ€๋ถ„ ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

์Šฌ๋ผ์ด์‹ฑ ๊ธฐ๋ฒ•์„ ์ด์šฉํ•˜๋ฉด a[์‹œ์ž‘๋ฒˆํ˜ธ:๋ ๋ฒˆํ˜ธ] ๋ฅผ ์ง€์ •ํ•  ๋–„ ๋ ๋ฒˆํ˜ธ์— ํ•ด๋‹นํ•˜๋Š” ๊ฒƒ์€ ํฌํ•จํ•˜์ง€ ์•Š๋Š”๋‹ค.

https://speedanddirection.tistory.com/2

 

ํŒŒ์ด์ฌ์˜ ๊ธฐ์ดˆ (๋ฌธ์ž์—ด ์ธ๋ฑ์‹ฑ๊ณผ ์Šฌ๋ผ์ด์‹ฑ)

#2 ํŒŒ์ด์ฌ chapter 2. ๋ฌธ์ž์—ด ์ธ๋ฑ์‹ฑ๊ณผ ์Šฌ๋ผ์ด์‹ฑ ์ธ๋ฑ์‹ฑ์ด๋ž€ ๋ฌด์—‡์ธ๊ฐ€๋ฅผ '๊ฐ€๋ฅดํ‚จ๋‹ค'๋Š” ์˜๋ฏธ์ด๊ณ , ์Šฌ๋ผ์ด์‹ฑ์€ ๋ฌด์—‡์ธ๊ฐ€๋ฅผ '์ž˜๋ผ๋‚ธ๋‹ค' ๋ผ๋Š” ์˜๋ฏธ์ด๋‹ค. *๋ฌธ์ž์—ด ์ธ๋ฑ์‹ฑ์ด๋ž€? >>> a="Life is too shrot, you need p

speedanddirection.tistory.com


print(10)
print(5 ** 2) # 5*5
print(5 ** 3) # 5*5*5

# ๋ฌธ์ž์—ด
# '', ""
#

multiline = '''
line1
line2
line3
'''

print(multiline)

a = " toto's house "
b = '              '
print(a, b)

#a = ' toto's house  '

#๋ฌธ์ž์—ด์˜ ๊ณฑํ•˜๊ธฐ
print(a*3)

# ๋ฌธ์ž์—ด ๊ธธ์ด ๊ตฌํ•˜๊ธฐ
print()

# ๋ฌธ์ž์—ด์˜ ์ธ๋ฑ์‹ฑ๊ณผ ์Šฌ๋ผ์ด์‹ฑ 
# ์ธ๋ฑ์‹ฑ -> ์ธ๋ฑ์Šค ๋ฒˆํ˜ธ๋กœ ๊ฐ’์„ ๋ฝ‘์•„๋‚ธ๋‹ค.
# ์Šฌ๋ผ์ด์‹ฑ -> ๋ฒ”์œ„๋กœ ๊ฐ’์„ ๋ฝ‘์•„๋‚ธ๋‹ค.

a = [1,2,3,4,5]
print(a[3]) #4
print(a[1:4]) #[2, 3, 4]

# format
print( "I eat {0} apples".format(3, 2) ) #I eat 3 apples
print( "I eat {0} {1}".format(3, "apples") ) #I eat 3 apples

# f๋ฌธ์ž์—ด ํฌ๋งคํŒ…
num = 3
fruits = "apples"
print( f"I eat {num} {fruits}" ) #I eat 3 apples

The 2 in your original example is essentially surplus and doesn't affect the output. It's an example of an unused argument in the format() method.


* extend, append ์ค‘์š”ํ•˜๋‹ค 


2-1 ์‹ค์Šต - *๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์ด์šฉํ•ด์„œ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ๊ฐ’์„ ๋„˜๊ฒจ๋ฐ›๊ณ , ์ถœ๋ ฅํ•˜๋Š” ๊ฒƒ.

""" def seasons(*args):  
    args = ('๋ด„', '์—ฌ๋ฆ„', '๊ฐ€์„', '๊ฒจ์šธ')
    print(args) """

def seasons(*args):
    print(args)
seasons("๋ด„", "์—ฌ๋ฆ„", "๊ฐ€์„", "๊ฒจ์šธ")

#('๋ด„', '์—ฌ๋ฆ„', '๊ฐ€์„', '๊ฒจ์šธ')

def print_seasons(*seasons):
    for season in seasons:
        print(season)

# ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๋ฉด์„œ ๊ณ„์ ˆ๋“ค์„ ๋„˜๊ฒจ์ค๋‹ˆ๋‹ค.
print_seasons("๋ด„", "์—ฌ๋ฆ„", "๊ฐ€์„", "๊ฒจ์šธ")
#๋ด„
#์—ฌ๋ฆ„
#๊ฐ€์„
#๊ฒจ์šธ
# ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๋ฉด์„œ ๊ณ„์ ˆ๋“ค์„ ๋„˜๊ฒจ์ค๋‹ˆ๋‹ค.
print_seasons("๋ด„", "์—ฌ๋ฆ„", "๊ฐ€์„", "๊ฒจ์šธ")

def mprint(*args):
    #print(args)
    for one in args:
        print(one)

mprint(1,2,3,4)    
#1
#2
#3
#4

[๋ ˆ๋ฒจ์—… ์‹ค์Šต 1] ๋ฌธ์ œ ์„ค๋ช…
์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ๋™๋ฌผ์˜ ์ข…๋ฅ˜์— ๋”ฐ๋ผ ํ•ด๋‹น ๋™๋ฌผ์˜ ์†Œ๋ฆฌ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑํ•˜์„ธ์š”. ์ด ํ•จ์ˆ˜๋Š” ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋™๋ฌผ์˜ ์ข…๋ฅ˜๋ฅผ ๋ฐ›์•„์„œ, ๊ฐ ๋™๋ฌผ์— ๋งž๋Š” ์†Œ๋ฆฌ๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ์ง€์›ํ•˜๋Š” ๋™๋ฌผ๊ณผ ์†Œ๋ฆฌ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

๊ฐœ: "๋ฉ๋ฉ"
๊ณ ์–‘์ด: "์•ผ์˜น"
์†Œ: "์Œ๋ฉ”"
์–‘: "๋งค"
๋‹ญ: "๊ผฌ๋ผ์˜ค"

def animal_print(*args):
    animal = input("๊ฐœ, ๊ณ ์–‘์ด, ์†Œ, ์–‘, ๋‹ญ ์ค‘์— ํ•˜๋‚˜๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”")
    #print(args)
    if animal == "๊ฐœ":
        print("๋ฉ๋ฉ")
    elif animal == "๊ณ ์–‘์ด":
        print("์•ผ์˜น")
    elif animal == "์†Œ":
        print("์Œ๋ฉ”")
    elif animal == "์–‘":
        print ("๋งค")
    else:
        print("๊ผฌ๋ผ์˜ค")   

animal_print()

https://wikidocs.net/26

 

04-3 ํŒŒ์ผ ์ฝ๊ณ  ์“ฐ๊ธฐ

์šฐ๋ฆฌ๋Š” ์ด ์ฑ…์—์„œ ์ด์ œ๊นŒ์ง€ ๊ฐ’์„ ‘์ž…๋ ฅ’๋ฐ›์„ ๋•Œ๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ์ง์ ‘ ์ž…๋ ฅํ•˜๋Š” ๋ฐฉ์‹์„ ์‚ฌ์šฉํ–ˆ๊ณ  ‘์ถœ๋ ฅ’ํ•  ๋•Œ๋Š” ๋ชจ๋‹ˆํ„ฐ ํ™”๋ฉด์— ๊ฒฐ๊ด๊ฐ’์„ ์ถœ๋ ฅํ•˜๋Š” ๋ฐฉ์‹์„ ์‚ฌ์šฉํ–ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ž…์ถœ๋ ฅ ๋ฐฉ๋ฒ•์ด …

wikidocs.net

 

728x90
๋ฐ˜์‘ํ˜•
Comments