Objective: To create 5 folds of training and test dataset using StratifiedKFold method.
I am able to print the indices alright but am unable to generate the actual folds. Here follows my code
I am able to print the indices alright but am unable to generate the actual folds. Here follows my code
from sklearn.cross_validation import StratifiedKFold import pandas as pd df=pd.read_csv('C:\Comb_features_to_be_used.txt') ##Getting only numeric columns p_input=df._get_numeric_data() ## Considering all the features except labels p_input_features = p_input.drop('labels',axis=1) ## Considering only labels [single column] p_input_label = p_input['labels'] skf = StratifiedKFold(p_input_label, n_folds=5, shuffle=True) i={1,2,3,4,5} for i,(train_index, test_index) in enumerate(skf): ##print("TRAIN:", train_index, "TEST:", test_index) p_input_features_train = p_input_features[train_index] p_input_features_test = p_input_features[test_index]