Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

Need Help with StratifiedShuffleSplit

$
0
0

@mohitlearns wrote:

Hello,

  1. I have one (“single”) data file with approx 20K features (rows / fields).

  2. I want to split this file between training data and test data in the ratio of 80:20 using Stratified Shuffle Split

  3. In this file there is an attributes named “Income” and I would like train and test data - each of these file to retain the percentage distribution of income from the original file

  4. I converted Income to Income discreet values under income_cat field

Here is the code snippet:

SSS = StratifiedShuffleSplit(housing[“income_cat”], test_size=0.2)
train_indices, test_indices = next(iter(SSS)) I get the following error on running this command
TypeError: ‘StratifiedShuffleSplit’ object is not iterable

I also tried
for train_index,test_index enumerate(SSS.split(housing[“income_cat”])
however I still get the same error

How can I get indexes from SSS when I just have one file to work with

Thanks,

Mohit

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles