Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle imbalanced classes ? #3

Open
smi45 opened this issue Sep 28, 2020 · 1 comment
Open

How to handle imbalanced classes ? #3

smi45 opened this issue Sep 28, 2020 · 1 comment

Comments

@smi45
Copy link

smi45 commented Sep 28, 2020

Hi, I have a use case wherein there are two classes and are hugely imbalanced. How can i fix this issue.

I have used the source code.

Sentiment Analysis with BERT

@ashfarhangi
Copy link

You can use my code and replace the cat1 and cat2 for your imbalance classes
from sklearn.utils import resample
cat_1= df[df.school_handle == 'ourmedschool']
cat_2= df[df.school_handle == 'ucfcah']

cat_large = df[df.school_handle == 'UCFCECS']
cat_1 = resample(cat_1,
replace=True,
n_samples=len(cat_large),
random_state=RANDOM_SEED)
cat_2 = resample(cat_2,
replace=True,
n_samples=len(cat_large),
random_state=RANDOM_SEED)

df1 = pd.merge(cat_1,cat_large,how='outer')
df1 = pd.merge(df1,cat_2,how='outer')
df1
sns.countplot(df1.school_handle)
plt.xlabel('College')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants