728x90
๋ฐ์ํ
๐ก
scikit-learn(sklearn) : ํ์ด์ฌ ์คํ์์ค์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค์์ ๋จธ์๋ฌ๋์ ๊ตฌํํ๋๋ฐ ํนํ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ.
scikit-learn
"We use scikit-learn to support leading-edge basic research [...]" "I think it's the most well-designed ML package I've seen so far." "scikit-learn's ease-of-use, performance and overall variety of algorithms implemented has proved invaluable [...]."

- sklearn์ ๊ฑฐ์ ๋๋ถ๋ถ์ ๋จธ์ ๋ฌ๋ ์๊ณ ๋ฆฌ์ฆ์ด ๊ตฌํ๋์ด ์๋ค.
- ๊ต์ฅํ ๊ตฌ์กฐ์ ์ผ๋ก ์ ๋ง๋ค์ด์ ธ ์์ด์, ์ฌ์ฉํ๊ธฐ ํธํฉ๋๋ค.
- ๋จธ์ ๋ฌ๋์ ์ํด์ ๋ง๋ค์ด์ง ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค ๋ณด๋, ๋ฅ๋ฌ๋์ ํ๊ธฐ์๋ ์ ํฉํ์ง ์๋ค.
- sklearn ์ดํ์ ๋ง๋ค์ด์ง ๋๋ถ๋ถ์ ๋จธ์ ๋ฌ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค์ด ๋ชจ๋ sklearn-style์ ๋ฐ๋ฅธ๋ค.
- Pycaret์ด๋ XGBoost, LightGBM, Catboost ๊ฐ์ ๋ํ์ ์ธ ๋จธ์ ๋ฌ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค๋ ๋ชจ๋ sklearn์ dependency๋ฅผ ๊ฐ์ง๊ณ ์์ต๋๋ค.
Getting Started
Getting Started
The purpose of this guide is to illustrate some of the main features that scikit-learn provides. It assumes a very basic working knowledge of machine learning practices (model fitting, predicting, cross-validation, etc.). Please refer to our installation instructions for installing scikit-learn . Scikit-learn is an open source machine learning library that supports supervised and unsupervised learning.

- ์์ ํ์ด์ง๋ฅผ ์ ๋ฐ๋ผ๊ฐ๋ฉด sklearn์ผ๋ก ์ฝ๊ฒ ๋ฐ์ดํฐ๋ฅผ ๋ถ๋ฌ์์ ํ์ตํ๋ ์ฝ๋๋ฅผ ๋ฐ๋ผ ๋ง๋ค ์ ์์ต๋๋ค.
- sklearn์ ์ ์ฒด์ ์ธ ๊ตฌํ ๋ฐฉ์์๋ ์ ํด์ง ํ์ด ์์ต๋๋ค.
# sklearn์ ์ฌ์ฉํ์ฌ ํ๋์ ML model์ ๋ถ๋ฌ์์ ๋ถ๋ฅ ๋ชจ๋ธ์ ํ์ตํ๊ณ ํ๊ฐํ๋ ์์์
๋๋ค.
# 1. ์ฌ์ฉํ ๋ชจ๋ธ์ ๋ถ๋ฌ์ต๋๋ค.
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
# 2. ๋ชจ๋ธ ๊ฐ์ฒด๋ฅผ ์ ์ธํฉ๋๋ค.
model = RandomForestClassifier()
# 3. training data๋ก ํ์ต์ ์งํํฉ๋๋ค.
model.fit(X_train, y_train)
# 4. test data๋ก inference๋ฅผ ์งํํฉ๋๋ค.
pred = model.predict(X_test)
# 5. Evaluation metric์ผ๋ก ํ๊ฐ๋ฅผ ์งํํฉ๋๋ค.
print("Accuracy : %.4f" % accuracy_score(y_test, pred))
>> Accuracy : 0.8976
- ์์ ์ฝ๋ ๊ตฌํ ๋ฐฉ์์ sklearn์ ์ฌ์ฉํ๋ ๋จธ์ ๋ฌ๋ ํ๋ก์ ํธ์์๋ ๊ณต์์ฒ๋ผ ํ์ฉ๋๋ ๋ฐ๋์ ์ตํ๋์ธ์!
Hands-on
- sklearn์ด ์ ๊ณตํ๋ ๋ถ๋ฅ ๋ชจ๋ธ์ค์ 3๊ฐ์ง ์ ๋๋ฅผ ์ฐพ์์ ์ด๋ฆ์ ์ ์ด๋ณด์ธ์.
- sklearn์์๋ ๋ชจ๋ ํ์ต์ ์ํํ๋ ํจ์๋ฅผ fit, ์์ธกํ๋ ํจ์๋ฅผ predict๋ก ๊ตฌํํ์์ต๋๋ค. ์ด๋ ๊ฒ ๊ตฌํํ์์ ๋์ ์ฅ์ ์ ๋ฌด์์ผ๊น์? (Hint: OOP)
728x90
๋ฐ์ํ
'AI Study > DeepLearning' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Chapter.03 Classification-02. Model 1: Linear Classifier (0) | 2023.04.19 |
---|---|
Chapter.03 Classification-01. ๋ถ๋ฅ์ ์ ์ (0) | 2023.04.14 |
Chapter.02 Machine Learning Workflow-01. ๋จธ์ ๋ฌ๋ ํ๋ก์ ํธ ์ํ๋ฐฉ๋ฒ (0) | 2023.04.14 |
Chapter.01 ๋จธ์ ๋ฌ๋ ๊ธฐ์ด ๊ฐ๋ -07. evaluation metric (0) | 2023.04.14 |
Chapter.01 ๋จธ์ ๋ฌ๋ ๊ธฐ์ด ๊ฐ๋ -06. loss function (0) | 2023.04.14 |