<aside>
</aside>
์ง๊ธ๊น์ง ์ฐ๋ฆฌ๋ ์ต๊ณ ์ ๋ชจ๋ธ์ ์ฐพ๊ณ , ๊ทธ ์ฑ๋ฅ์ ๊ทนํ๊น์ง ๋์ด์ฌ๋ ธ์ต๋๋ค. Rยฒ ์ ์ 0.8824! ์ ๋ง ํ๋ฅญํ ์ฑ๊ณผ์ฃ . ํ์ง๋ง ์ด ์ซ์ ํ๋๊ฐ ๋ชจ๋ธ์ ๋ชจ๋ ๊ฒ์ ๋งํด์ฃผ์ง๋ ์์ต๋๋ค. ๋ชจ๋ธ์ ์ด๋ค ๋ฐ์ดํฐ์์ ์ค์๋ฅผ ํ๊ณ , ์ด๋ค ํน์ง(feature)์ ์ค์ํ๊ฒ ์๊ฐํ ๊น์? ์ด๋ฒ ์๊ฐ์๋ ์ซ์ ๋๋จธ์ ์๋ ๋ชจ๋ธ์ ์ง์ง ์ด์ผ๊ธฐ๋ฅผ ๋ค์ด๋ณด๋ ์๊ฐ์
๋๋ค. plot_model
๊ณผ evaluate_model
์ด๋ผ๋ ๊ฐ๋ ฅํ ์๊ฐํ ๋๊ตฌ๋ฅผ ์ฌ์ฉํด ๋ชจ๋ธ์ ๋ด๋ฉด์ ๊น์์ด ๋ค์ฌ๋ค๋ณด๋ '๋ชจ๋ธ ํ์ '์ด ๋์ด๋ณด๊ฒ ์ต๋๋ค.
plot_model()
ํจ์๋ฅผ ์ฌ์ฉํด ๋ชจ๋ธ์ ์ฑ๋ฅ์ ๋ถ์ํ๋ ๋ค์ํ ์ ์ ๊ทธ๋ํ๋ฅผ ์์ฑํ ์ ์์ต๋๋ค.evaluate_model()
ํจ์๋ฅผ ์ฌ์ฉํด ํ๋์ ์ธํฐํ์ด์ค์์ ๋ชจ๋ ํ๊ฐ ์งํ๋ฅผ ์ธํฐ๋ํฐ๋ธํ๊ฒ ํ์ํ ์ ์์ต๋๋ค.plot_model
๊ณผ ํ์์ฉ evaluate_model
์ ๊ฐ๊ธฐ ๋ค๋ฅธ ์ฌ์ฉ ์ฌ๋ก๋ฅผ ์ดํดํฉ๋๋ค.๐ก 7๊ฐ์์ ์์ฑํ tuned_gbr_model์ ์ฌ์ฉํ์ฌ, ๋ชจ๋ธ์ ์ฑ๋ฅ๊ณผ ํน์ฑ์ ์๊ฐ์ ์ผ๋ก ๋ถ์ํฉ๋๋ค.
# 1. ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ฐ ํ๋๋ ๋ชจ๋ธ ์ค๋น (1~7๊ฐ ๋ด์ฉ)
from pycaret.datasets import get_data
from pycaret.regression import setup, create_model, tune_model, plot_model, evaluate_model
# ๋ฐ์ดํฐ ๋ก๋ ๋ฐ ์ค์
df = get_data('insurance')
setup(data=df, target='charges', session_id=123, fold_shuffle=True)
# ๋ชจ๋ธ ์์ฑ ๋ฐ ํ๋
base_model = create_model('gbr')
tuned_gbr_model = tune_model(base_model, optimize='R2', n_iter=200)
# 2. ๊ฐ๋ณ ํ๋กฏ ์์ฑํ๊ธฐ (๋ณด๊ณ ์/์ ์ฅ์ฉ)
# ์์ฐจ ํ๋กฏ (Residuals Plot)
plot_model(tuned_gbr_model, plot = 'residuals')
# ํน์ฑ ์ค์๋ ํ๋กฏ (Feature Importance Plot)
plot_model(tuned_gbr_model, plot = 'feature')
# 3. ์ธํฐ๋ํฐ๋ธ ๋์๋ณด๋ ์คํ (ํ์์ฉ)
# Jupyter Notebook ํ๊ฒฝ์์ ์คํํด์ผ UI๊ฐ ๋ํ๋ฉ๋๋ค.
evaluate_model(tuned_gbr_model)
plot_model(plot='residuals')
์คํ ๊ฒฐ๊ณผGraph
plot_model(plot='feature')
์คํ ๊ฒฐ๊ณผGraph