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

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

[9] 241111 ML, DL [Goorm All-In-One Pass! AI Project Master - 4th Session, Day 9] ๋ณธ๋ฌธ

๐ŸŒณAI & Quantum Computing Bootcamp 2024โœจ/AI Lecture Revision

[9] 241111 ML, DL [Goorm All-In-One Pass! AI Project Master - 4th Session, Day 9]

yjyuwisely 2024. 11. 11. 11:37

241111 Mon 9th class

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


ํ”„๋กœ์ ํŠธ ๋ฐœํ‘œ 


์ตœ์‹  ๋ชจ๋ธ ๋น„๊ต
RAG Lanchain

ํ˜„์‹ค ๋””์ž์ธ์œผ๋กœ ์ ์šฉ 

ํŒŒ์ธํŠœ๋‹ (์„ฑ๋Šฅ ์˜ฌ๋ฆผ) 


ํ”„๋กœ์ ํŠธ๋กœ ๊ฐ€๋Šฅ์„ฑ์„ ๋ณด์—ฌ์ค€๋‹ค. 

์‹ค๋ฌด, ์‹ค์งˆ์ ์ธ ๊ฒƒ์œผ๋กœ ๊ณต๋ถ€ 

์–‡์€ ์ฑ…์„ ์‚ฐ๋‹ค. 

๋ชจ๋ฅด๋ฉด ๋…ธ๊ฐ€๋‹ค

์„ฑ๋Šฅ ์˜ฌ๋ฆฌ๋Š” ๊ฒƒ ๋‚œ์ด๋„ ๋†’์Œ, ํ•œ๊ณ„O

ํ•˜๋‚˜์˜ ์ „๋ฌธ ๋ถ„์•ผ ํ•„์š” 

๊ฐ€๊ณ ์žํ•˜๋Š” ๋ถ„์•ผ๋ฅผ ๊ตฌ์ฒด์ ์œผ๋กœ ์ •ํ•˜๊ณ , ์ „๋ฌธ๊ฐ€๊ฐ€ ๋œ๋‹ค.

ex) ๊ต์œก, ์ดˆ์ค‘๊ธ‰์— ๋งž์ถ”์ž, ๊ณ„์† ๊ฐ•์˜์ค‘ 

๊ธฐ๋ณธ์„ ๋ชจ๋ฅด๊ณ  ํ•˜๋ฉดX 

์ฑ…์„ 1๊ถŒ ๋ด์•ผํ•œ๋‹ค. ๋งจ๋‚  LLMํ•  ์ˆ˜๋Š” X

๋น…๋ฐ์ดํ„ฐ๊ธฐ์‚ฌ 

๊ธฐ๋ณธ์„ ์•„๋Š” ์‚ฌ๋žŒ๊ณผ ๋ชจ๋ฅด๋Š” ์‚ฌ๋žŒ์˜ ์ฐจ์ด๊ฐ€ ํฌ๋‹ค 

AI ์•Œ๊ณ  ํ™œ์šฉํ•˜๋Š” ์‚ฌ๋žŒ, ์•ˆ ํ•˜๋Š” ์‚ฌ๋žŒ ์ฐจ์ด๊ฐ€ ํฌ๋‹ค 

๋ณ€ํ™”์˜ ์‹œ๊ธฐ์— ๋‚˜์˜ ์—ญ๋Ÿ‰์„ ํ‚ค์šด๋‹ค 

๊ณ„์† ๊ณต๋ถ€, ๋ฐœ์ „์‹œ์ผœ ๋‚˜๊ฐ„๋‹ค -> ์„ฑ์žฅ, ๋ฐœ์ „ 

AI๊ฐ€ ์ผ์ž๋ฆฌ ์žƒ๊ฒŒ ํ•จ
ํ•˜์ง€๋งŒ ๊ทธ ๋ณ€ํ™” ์†์—์„œ AI ์•Œ๊ณ  ์ดํ•ดํ•˜๋Š” ์‚ฌ๋žŒ์˜ ์ž๋ฆฌ๋Š” ์ƒ๊ธด๋‹ค. 

์ค€๋น„ -> ์‹œ๊ธฐ -> Try

๋ณ€ํ™”์˜ ์‹œ๊ธฐ, ๋” ํฐ ๊ธฐํšŒO

ํ”„๋กœ์ ํŠธ ์ œ์•ˆ ๊ฐ€๋Šฅ (์ˆ˜์š”์ผ) 


https://github.com/LDJWJ/ML_Basic_Class

 

GitHub - LDJWJ/ML_Basic_Class

Contribute to LDJWJ/ML_Basic_Class development by creating an account on GitHub.

github.com

https://github.com/LDJWJ/DL_Basic

 

GitHub - LDJWJ/DL_Basic

Contribute to LDJWJ/DL_Basic development by creating an account on GitHub.

github.com


https://rowan-sail-868.notion.site/0fc66cdf182c4e24be0dc0e09a91d5dc

 

๋จธ์‹ ๋Ÿฌ๋‹ ์ดˆ๋ณด ์ฒซ๊ฑธ์Œ | Notion

Notion ํŒ: ํŽ˜์ด์ง€๋ฅผ ์ƒ์„ฑํ•  ๋•Œ๋Š” ๋ช…ํ™•ํ•œ ์ œ๋ชฉ๊ณผ ๊ด€๋ จ๋œ ๋‚ด์šฉ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ์ธ์ฆ๋œ ์ •๋ณด๋ฅผ ์‚ฌ์šฉํ•˜๊ณ , ํŽ˜์ด์ง€ ์ฃผ์ œ๋ฅผ ํ™•์‹คํžˆ ํ•˜๊ณ , ์ฃผ์š” ์ด์Šˆ์— ๋Œ€ํ•œ ์˜๊ฒฌ์„ ๊ณต์œ ํ•˜์„ธ์š”.

rowan-sail-868.notion.site

https://colab.research.google.com/drive/1nEuXxqNNHSVMlE4-Y2syZjFZSifOonHm#scrollTo=rMLqPtwDixg7

 

Google Colab Notebook

Run, share, and edit Python notebooks

colab.research.google.com

https://ldjwj.github.io/ML_Basic_Class/part03_ml/part03_ch01_01_ml/ch01_01_ML%EC%9E%85%EB%AC%B8_v13_202404.pdf


์ธ๊ณต์ง€๋Šฅ > ๋จธ์‹ ๋Ÿฌ๋‹ > ๋”ฅ๋Ÿฌ๋‹ 
๋”ฅ๋Ÿฌ๋‹ ์‚ฌ์šฉ ๋งŽ์ด ๋จ, ์ปค์ง


๊ฐœ๋ฐœ (๋‚˜) -> ์ปฌ๋Ÿผ

target

๊ณต์‹ y=f(x)
x๋ฅผ ๋…๋ฆฝ๋ณ€์ˆ˜
, y๋ฅผ ์ข…์†๋ณ€์ˆ˜
Yes, in the context of machine learning, y is typically referred to as the target or label.

๋จธ์‹  ๋Ÿฌ๋‹: y ๊ฐ’ ์˜ˆ์ธก
๋ฐ์ดํ„ฐ ๋งˆ์ด๋‹: y ๊ฐ’ ์˜ˆ์ธก์— ์˜ํ–ฅ ๋ผ์น˜๋Š” ๊ฒƒ ๊ถ๊ธˆ 


์„ ํ˜• ํšŒ๊ท€(็ทšๅž‹ๅ›žๆญธ, ์˜์–ด: linear regression)๋Š” ์ข…์† ๋ณ€์ˆ˜ y์™€ ํ•œ ๊ฐœ ์ด์ƒ์˜ ๋…๋ฆฝ ๋ณ€์ˆ˜ (๋˜๋Š” ์„ค๋ช… ๋ณ€์ˆ˜) X์™€์˜ ์„ ํ˜• ์ƒ๊ด€ ๊ด€๊ณ„๋ฅผ ๋ชจ๋ธ๋งํ•˜๋Š” ํšŒ๊ท€๋ถ„์„

y-tip = total_bill + size


x๊ฐ€ 3๊ฐœ, 4์ฐจ์›, ์ดˆํ‰๋ฉด 

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np

# Generate some example data
np.random.seed(0)
x1 = np.random.rand(50) * 10  # Random values for x1
x2 = np.random.rand(50) * 10  # Random values for x2
x3 = np.random.rand(50) * 10  # Random values for x3
y = x1 * 0.3 + x2 * 0.5 + x3 * 0.2  # Example relation for y

# Plotting the 3D space
fig = plt.figure(figsize=(10, 7))
ax = fig.add_subplot(111, projection='3d')
sc = ax.scatter(x1, x2, x3, c=y, cmap='viridis', s=50)

# Labeling the axes
ax.set_xlabel('X1')
ax.set_ylabel('X2')
ax.set_zlabel('X3')
plt.colorbar(sc, label="Y (Target Value)")

# Display the plot
plt.title("3D Space Representation with X1, X2, X3 and Y")
plt.show()

 

 


Label Encoding

  • ๊ฐ ๊ณ ์œ ํ•œ ๋ฌธ์ž ๊ฐ’์„ ์ˆซ์ž ๊ฐ’์œผ๋กœ ๋งคํ•‘ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ['male', 'female']์„ ๊ฐ๊ฐ 0๊ณผ 1๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
  • ์นดํ…Œ๊ณ ๋ฆฌํ˜• ๋ฐ์ดํ„ฐ๊ฐ€ ์„œ์—ด ๊ด€๊ณ„๊ฐ€ ์žˆ์„ ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
from sklearn.preprocessing import LabelEncoder
encoder = LabelEncoder()
df['sex'] = encoder.fit_transform(df['sex'])  # 'male' -> 1, 'female' -> 0

One-Hot Encoding

  • ๊ฐ ์นดํ…Œ๊ณ ๋ฆฌ ๊ฐ’๋งˆ๋‹ค **๋ณ„๋„์˜ ์—ด(column)**์„ ์ถ”๊ฐ€ํ•˜๊ณ , ๊ฐ’์ด ์žˆ๋Š” ๊ฒฝ์šฐ 1, ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด 0์„ ํ• ๋‹นํ•ฉ๋‹ˆ๋‹ค.
  • ์˜ˆ๋ฅผ ๋“ค์–ด, ['Monday', 'Tuesday', 'Wednesday']๋Š” ๊ฐ๊ฐ์˜ ์š”์ผ์„ ์—ด๋กœ ๋งŒ๋“ค์–ด [1, 0, 0], [0, 1, 0], [0, 0, 1]์ฒ˜๋Ÿผ ํ‘œํ˜„ํ•ฉ๋‹ˆ๋‹ค.
  • ์ฃผ๋กœ ์„œ์—ด์ด ์—†๋Š” ๋ฒ”์ฃผํ˜• ๋ฐ์ดํ„ฐ์— ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
import pandas as pd
df = pd.get_dummies(df, columns=['day'])

Embedding

  • ํ…์ŠคํŠธ์™€ ๊ฐ™์€ ๋ณต์žกํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฒกํ„ฐ๋กœ ํ‘œํ˜„ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ๊ฐ ๋‹จ์–ด๋‚˜ ๋ฌธ์žฅ์„ ๊ณ ์ฐจ์› ๋ฒกํ„ฐ ๊ณต๊ฐ„์˜ ์ˆซ์ž ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
  • ๋”ฅ๋Ÿฌ๋‹์—์„œ ์ฃผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ, ์›Œ๋“œ ์ž„๋ฒ ๋”ฉ(Word Embedding) ๊ธฐ๋ฒ•์—๋Š” Word2Vec, GloVe, BERT ๋“ฑ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

Ordinal Encoding

  • ๋ฌธ์ž๊ฐ€ ํŠน์ • ์ˆœ์„œ๋‚˜ ํฌ๊ธฐ๋ฅผ ํ‘œํ˜„ํ•  ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ['low', 'medium', 'high']๋ฅผ [0, 1, 2]๋กœ ๋ณ€ํ™˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

print( tips['sex'].unique() )
print( tips['smoker'].unique() )
print( tips['day'].unique() )
print( tips['time'].unique() )
print( tips['size'].unique() )
mapval = {'Female':0, 'Male':1}
tips['sex_mapped'] = tips['sex'].map(mapval)
tips

 

7-2 ์‹ค์Šต 2- smoker๊ณผ day๋ฅผ ๋ณ€์ˆ˜์— ์ถ”๊ฐ€ํ•ด์„œ ๋ชจ๋ธ์„ ๊ตฌ์ถ•ํ•ด ๋ณด๊ธฐ.

์—ฐ์†ํ˜•, ๋ฒ”์ฃผํ˜•

 

๋ฐ์ดํ„ฐ ํŠน์ˆ˜์„ฑ ์„ค๋ช…ํ•  ์ˆ˜ ์žˆ์–ด์•ผ ํ•จ


https://rebro.kr/184

 

[๋จธ์‹ ๋Ÿฌ๋‹] K-์ตœ๊ทผ์ ‘ ์ด์›ƒ ํšŒ๊ท€ (K-NN Regression) ๊ฐœ๋… ๋ฐ ์‹ค์Šต

[๋ชฉ์ฐจ] 1. K-NN Regression 2. KNeighborsRegressor Class 3. K-NN Regression ์‹ค์Šต 4. ๊ณผ๋Œ€์ ํ•ฉ vs ๊ณผ์†Œ์ ํ•ฉ 5. K-NN Regression์˜ ํ•œ๊ณ„ 1. K-NN Regression ์ด์ „์—๋Š” ์ƒ์„ ์ด ๋„๋ฏธ์— ์†ํ•˜๋Š”์ง€ ๋น™์–ด์— ์†ํ•˜๋Š”์ง€ '๋ถ„๋ฅ˜'ํ•˜๋Š” ๋ฌธ์ œ๋ฅผ

rebro.kr

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