๐Ÿ˜Ž ๊ณต๋ถ€ํ•˜๋Š” ์ง•์ง•์•ŒํŒŒ์นด๋Š” ์ฒ˜์Œ์ด์ง€?

๋‚˜์ค‘์— ์ฐธ๊ณ ํ•  ์ฝ”๋“œ ์†Œ์Šค ๋ณธ๋ฌธ

๐Ÿ‘ฉ‍๐Ÿ’ป ์ปดํ“จํ„ฐ ๊ตฌ์กฐ/etc

๋‚˜์ค‘์— ์ฐธ๊ณ ํ•  ์ฝ”๋“œ ์†Œ์Šค

์ง•์ง•์•ŒํŒŒ์นด 2022. 9. 14. 10:55
728x90
๋ฐ˜์‘ํ˜•

 

 

๐ŸŸฃ ์‹œ๊ณ„์—ด ๋ฐ์ดํ„ฐ ๋น„์Šทํ•œ ํŒŒ์ผ์„ ๊ทธ๋ž˜ํ”„ ๋ถ„ํฌ๋กœ ๋‚˜ํƒ€๋‚ด๊ธฐ

## plot feature data distribution

fig, ax = plt.subplots(2, train.shape[1]//2+1, figsize=(20, 6))

for idx, feature in enumerate(train.columns):
    data = train[feature]
    if idx<train.shape[1]//2 + 1:
        ax[0,idx].hist(train.iloc[:,idx], bins=10, alpha=0.5)
        ax[0,idx].set_title(train.columns[idx])
    else:
        ax[1,idx-train.shape[1]//2-1].hist(train.iloc[:,idx], bins=10, alpha=0.5)
        ax[1,idx-train.shape[1]//2-1].set_title(train.columns[idx])
plt.show()

ex) ํƒœ์–‘๊ด‘ ๋ฐœ์ „๋Ÿ‰ ์˜ˆ์ธก

 

 

 

๐ŸŸฃ Optuna ๋กœ ํ•˜์ดํผ ํŒŒ๋ผ๋ฏธํ„ฐ ํŠœ๋‹

์ถœ์ฒ˜: https://sswwd.tistory.com/34?category=1194933 [๋ฏผ๊ณต์ง€๋Šฅ:ํ‹ฐ์Šคํ† ๋ฆฌ]

 pip install optuna
def objective(trial):
    from sklearn.svm import SVC
    params = {
        'C': trial.suggest_loguniform('C', 0.01, 0.1),
        'gamma': trial.suggest_categorical('gamma', ["auto"]),
        'kernel': trial.suggest_categorical("kernel", ["rbf"])
    }

    svc = SVC(**params, verbose=True)
    svc.fit(X_train, y_train)
    return svc.score(X_test, y_test)

study = optuna.create_study(sampler=optuna.samplers.TPESampler(seed=123),
                            direction="maximize",
                            pruner=optuna.pruners.MedianPruner())
study.optimize(objective, n_trials=5, show_progress_bar=True)

print(f"Best Value from optune: {study.best_trial.value}")
print(f"Best Params from optune: {study.best_params}")

 

 

 

 

 

 

 

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