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

IndexError: tuple index out of range #4896

Closed
erotavlas opened this issue Sep 25, 2019 · 1 comment · Fixed by #4929
Closed

IndexError: tuple index out of range #4896

erotavlas opened this issue Sep 25, 2019 · 1 comment · Fixed by #4929

Comments

@erotavlas
Copy link

I keep getting this error and I don't know how to solve it, as far as I know my data is in the correct format, single columns for both x and y

      File "D:\Anaconda\envs\py3.6\lib\site-packages\xgboost-1.0.0_snapshot-py3.6.egg\xgboost\sklearn.py", line 680, in fit
        self._features_count = X.shape[1]
    
    IndexError: tuple index out of range

Code to reproduce this is as follows (run on Windows 10 x64 machine, XGBoost installed to Anaconda env)

    import numpy as np
    from sklearn.datasets import fetch_20newsgroups
    twenty_train = fetch_20newsgroups(subset='train', shuffle=True)
    
    import os
    mingw_path = 'C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin'
    os.environ['PATH'] = mingw_path + ';' + os.environ['PATH']
    
    import xgboost as xgb
    from xgboost import XGBClassifier
    
    from sklearn.model_selection import train_test_split
    
    x_train, x_test, y_train, y_test = train_test_split(np.array(twenty_train.data), np.array(twenty_train.target), test_size=0.2, random_state=1)
    model = XGBClassifier()
    model.fit(x_train, y_train)
@trivialfis
Copy link
Member

Seems feature name is not prepared for 1d data. Will fix it.

trivialfis added a commit to trivialfis/xgboost that referenced this issue Oct 10, 2019
trivialfis added a commit that referenced this issue Oct 12, 2019
* Remove nthread, seed, silent. Add tree_method, gpu_id, num_parallel_tree. Fix #4909.
* Check data shape. Fix #4896.
* Check element of eval_set is tuple. Fix #4875
*  Add doc for random_state with hogwild. Fixes #4919
@lock lock bot locked as resolved and limited conversation to collaborators Jan 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants