728x90 반응형 SMALL class weight2 [Machine Learning] 클래스 가중치 (Class Weight) 클래스 가중치 (Class Weight) from sklearn.model_selection import GridSearchCV from sklearn.ensemble import RandomForestClassifier # 분류기와 파라미터 그리드 정의 classifier = RandomForestClassifier() param_grid = { 'class_weight': ['balanced', None], 'max_depth': [3, 5, 10], 'n_estimators': [80, 100, 150] } # GridSearchCV를 사용하여 최적의 파라미터 찾기 grid_search = GridSearchCV(classifier, param_grid, cv=5) grid_search.fit(X_.. 2023. 9. 22. [Keras] ImageDataGenerator class weight ImageDataGenerator class weight 딥러닝시 이미지 데이터의 불균형 문제를 해결하기 위해 class에 따른 가중치를 다르게 부여할 수 있다. from sklearn.utils import compute_class_weight import numpy as np train_classes = train_generator.classes class_weights = compute_class_weight( class_weight = "balanced", classes = np.unique(train_classes), y = train_classes ) class_weights = dict(zip(np.unique(train_classes), class_weights)) model.fit_gen.. 2023. 9. 8. 이전 1 다음 728x90 반응형 LIST