1
$\begingroup$

Problem

Hey everyone. I think I am missing something incredibly easy, but because I am wokring in resampling for the first time it is giving me all sorts of inadequacy. I performed an ADASYN up sample to my majorly imbalanced dataset and the numbers look very good to me while I am doing diagnostics.

It appears to me that my X_res and y_res variables are coming in incorrect into the prompt nad it is reading them at the split as being of length [48501, 48501].

The diagnostic code suggests to me that it should be [48501, 24411] however and I cannot seem to be able to find where the discrepancy is.

I'd love to hear if anyone has any thoughts on this.

Code

ada = ADASYN(random_state=42)
X_res, y_res = ada.fit_resample(X, y)
print('Resampled dataset shape %s' % Counter(y_res))
X_res = X_res.fillna(0)
print('Resampled dataset shape for X %s' % len(X_res), 'and y %s' % len(y_res))
Resampled dataset shape for X 48501 and y 48501
AX_train, AX_test, Ay_train, Ay_test = train_test_split(X_res, y_res, test_size = 0.2, random_state=27, stratify=y)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-74-1d75049a692e> in <module>

----> 1 AX_train, AX_test, Ay_train, Ay_test = train_test_split(X_res, y_res, test_size = 0.2, random_state=27, stratify=y)

...

~\Anaconda3\lib\site-packages\sklearn\utils\validation.py in check_consistent_length(*arrays)

254     uniques = np.unique(lengths)
255     if len(uniques) > 1:
--> 256         raise ValueError("Found input variables with inconsistent numbers of" 
257                          " samples: %r" % [int(l) for l in lengths])
258 

ValueError: Found input variables with inconsistent numbers of samples: [48501, 24411]
$\endgroup$
1
  • $\begingroup$ What is the actual shape of X_res are you expecting that to be a 1d array? or 2d? i.e. rows of features? and what are the inputs, fillna() is not a numpy method is it? $\endgroup$ Mar 18 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.