'sklearn'에 해당되는 글 2건
- 2022.05.30 :: [python] sklearn RandomizedSearchCV
- 2020.02.29 :: [Text 분석] Scikit-Learn의 문서 전처리 기능
Python
2022. 5. 30. 11:50
GridSearch와 동일한 방식으로 사용하지만, 모든 조합을 시도하지 않고 각 반복마다 임의의 값만 대입해 지정한 횟수만큼 평가
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import RandomizedSearchCV
X = []
Y = []
xtrain, xtest, ytrain, ytest = train_test_split(X,Y,random_state=1234)
rf = RandomForestClassifier()
n_estimators = [int(x) for x in np.linspace(start = 200, stop = 2000, num = 10)]
max_features = ['auto', 'sqrt']
max_depth = [int(x) for x in np.linspace(10, 110, num = 11)]
max_depth.append(None)
min_samples_split = [2, 5, 10]
min_samples_leaf = [1, 2, 4]
bootstrap = [True, False]
random_grid = {'n_estimators': n_estimators,
'max_features': max_features,
'max_depth': max_depth,
'min_samples_split': min_samples_split,
'min_samples_leaf': min_samples_leaf,
'bootstrap': bootstrap}
print(random_grid)
rf_random = RandomizedSearchCV(estimator = rf, param_distributions = random_grid, n_iter = 100, cv = 3, verbose=2, random_state=42, n_jobs = -1)
# Fit the random search model
rf_random.fit(xtrain,ytrain)
best_random = rf_random.best_estimator_
best_random.score(xtest,ytest)
'Python' 카테고리의 다른 글
loc을 이용한 data 변경 (0) | 2022.06.07 |
---|---|
Isolation Forest와 One-Class SVM (0) | 2022.06.03 |
[python] dataframe column index 가져오기 (0) | 2022.05.30 |
[Python]이미지 파일 불러와서 일자별로 폴더 생성 후 복사 (0) | 2022.05.29 |
dataframe groupby agg percentile (0) | 2022.05.02 |
Python
2020. 2. 29. 21:20
https://datascienceschool.net/view-notebook/3e7aadbf88ed4f0d87a76f9ddc925d69/
Data Science School
Data Science School is an open space!
datascienceschool.net
'Python' 카테고리의 다른 글
Pandas Big Data 다루기 (0) | 2020.03.18 |
---|---|
ValueError: If using all scalar values, you must pass an index (0) | 2020.03.09 |
[Text 분석] 전처리 - URL, HTML, emoji, punctuations 삭제 함수 (0) | 2020.02.29 |
[KoNLPy] 쉽고 간결한 한국어 정보처리 파이썬 패키지 (제 26회 한글 및 한국어 정보처리 학술대회 논문집 2014년) (0) | 2019.08.25 |
apscheduler (0) | 2019.02.11 |