0
from collections import Counter
from sklearn.datasets import make_classification
from sklearn.decomposition import PCA
from imblearn.over_sampling import SMOTE
from imblearn.over_sampling import ADASYN

#Oversample using Adaptive Synthetic (ADASYN) algorithm

df_train = pd.read_csv('F:/Master_study/Research_data/data/lankershim_label_data.csv')

# Divide by class

X = df_train[df_train['target'] =='keep']
y = df_train[df_train['target'] =='changing']
X, y = ada.fit_resample(X, y)
ada = ADASYN(random_state=42)
X_resampled, y_resampled = ada.fit_resample(X, y)
X_res_vis = pca.transform(X_resampled)
print('Resampled dataset shape {}'.format(Counter(y_res)))

I am trying to do handle imbalanced data, and regenerate my label (which is less in number)

Jason Yang
  • 11,284
  • 2
  • 9
  • 23
  • 2
    Please give more details such as which line is giving such an issue and the full error. – hypadr1v3 Jun 03 '21 at 08:05
  • Not the issue, but are you sure lines like `X =df_train[df_train['target'] =='keep']` are doing the right thing? This is going to be `X = df_train[True]` (or False) – blueteeth Jun 03 '21 at 08:09
  • X=df_train[True] is also not working – owais lateef Jun 03 '21 at 08:28
  • is there anyway to assign value in X and y? – owais lateef Jun 03 '21 at 08:29
  • Error is not mentioned in any line. It just shoeing that '<' not supported between instances of 'str' and 'float'. – owais lateef Jun 03 '21 at 08:31
  • @blueteeth Those lines are actually a feature of pandas dataframes. `==` and indexing are both overloaded. – Jasmijn Jun 03 '21 at 08:40
  • @jasmijn did you my problem? If yes suggest some solution – owais lateef Jun 03 '21 at 09:19
  • @owaislateef No, it is hard to help you without more information, such as the stack trace or a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). See also [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples/20159305#20159305). – Jasmijn Jun 03 '21 at 10:19

0 Answers0