You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.
@eubinecto 이런식으로 구현했었습니다.
wisdom이 df에서 언급된 세고 그중 제일 많은 걸 기준으로 나머지 데이터들도 랜덤하게 업샘플링되게 해뒀습니다.
(코드 다시보니 왜 카운팅을 저런식으로 해뒀는 지 잘 이해가 안되네요 ㅋㅋㅋㅋㅋ 그냥 그룹 소트 하면 됐을텐데 ㅋㅋㅋ)
업샘플링의 경우 사이킷런 써서 랜덤하게 업샘플링 시켰습니다.
별거 없어서 지금 해둘게요
fromcollectionsimportCounterfromsklearn.utilsimportresamplecounts=sorted(Counter(data_df['wisdom']).items(), key=lambdar: r[1], reverse=True)
major=counts[0]
# Upsample minority classtotal_df=data_df.loc[data_df['wisdom'] ==major[0]]
forwis, ctincounts[1:]:
df_minority_upsampled=resample(data_df[data_df['wisdom'] ==wis],
replace=True, # sample with replacementn_samples=major[1], # to match majority classrandom_state=123) # reproducible resultstotal_df=total_df.append(df_minority_upsampled)
returntotal_df
What?
가장 데이터 개수가 많은 클래스에 맞춰서, 상대적으로 개수가 적은 클래스의 데이터를 upsample하는 함수
The text was updated successfully, but these errors were encountered: