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

Found input variables with inconsistent numbers #10

Closed
shaoweiwang opened this issue Sep 26, 2018 · 3 comments
Closed

Found input variables with inconsistent numbers #10

shaoweiwang opened this issue Sep 26, 2018 · 3 comments

Comments

@shaoweiwang
Copy link

shaoweiwang commented Sep 26, 2018

Hello @WillKoehrsen, thanks for your magic functions.
However, I tried to follow the tutorial for my CSV file for a regression learning, and in the end I received a message. Here are the codes:

` file_name = 'GYT_0.csv'
train = pd.read_csv(io.StringIO(uploaded[file_name].decode('ISO-8859-1')),sep=';')
train_labels = ['Delaitotal']
train = train.drop(columns = ['Delaitotal'])

fs = FeatureSelector(data = train, labels = train_labels)
fs.identify_zero_importance(task = 'regression',eval_metric = 'l2') `

Here is the message:

Training Gradient Boosting Model


ValueError Traceback (most recent call last)
in ()
1
2
----> 3 fs.identify_zero_importance(task = 'regression',eval_metric = 'l2')
4
5

/content/feature_selector.py in identify_zero_importance(self, task, eval_metric, n_iterations, early_stopping)
304 if early_stopping:
305
--> 306 train_features, valid_features, train_labels, valid_labels = train_test_split(features, labels, test_size = 0.15)
307
308 # Train the model with early stopping

/usr/local/lib/python3.6/dist-packages/sklearn/model_selection/_split.py in train_test_split(*arrays, **options)
2029 test_size = 0.25
2030
-> 2031 arrays = indexable(*arrays)
2032
2033 if shuffle is False:

/usr/local/lib/python3.6/dist-packages/sklearn/utils/validation.py in indexable(*iterables)
227 else:
228 result.append(np.array(X))
--> 229 check_consistent_length(*result)
230 return result
231

/usr/local/lib/python3.6/dist-packages/sklearn/utils/validation.py in check_consistent_length(*arrays)
202 if len(uniques) > 1:
203 raise ValueError("Found input variables with inconsistent numbers of"
--> 204 " samples: %r" % [int(l) for l in lengths])
205
206

ValueError: Found input variables with inconsistent numbers of samples: [25446, 1]

Environment: Google colab
Python version: 3.6.3

Thank you in advance.

@WillKoehrsen
Copy link
Owner

Did you figure out what the error was? If so, it might be helpful to post the solution here for others!

@shaoweiwang
Copy link
Author

shaoweiwang commented Dec 20, 2018

As a matter of fact, there was an error in my code:

train_labels = ['Delaitotal'] should be train_labels = train['Delaitotal']

And problem solved.

@WillKoehrsen
Copy link
Owner

I am glad you were able to figure out the problem!

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