in Education by
I wish to divide pandas dataframe to 3 separate sets. I know by using train_test_split from sklearn.cross_validation, one can divide the data in two sets (train and test). but, to perform these I couldn't find any solution about splitting the data into three sets. most preferably, I would like to have the indices of the original data. I know here we would be using train_test_split two times and somehow we can adjust the indices. But is these a standard or built-in way to split the data into 3 sets instead of 2? kindly help Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
You can split your dataset into train,validation and test using the numpy.split() method: Syntax- numpy.split(array,indices_or_sections,axis=0) Example- >>> a= np.arange(9.0) >>> np.split(a, 3) [array([ 0., 1., 2.]), array([ 3., 4., 5.]), array([ 6., 7., 8.])] To Learn what is python and python applications then visit this python for data science course.

Related questions

0 votes
    How to split data into 3 sets (train, validation and test)?...
asked Nov 20, 2020 in Education by Editorial Staff
0 votes
    What exactly is the difference between groupby("x").count and groupby("x").size in Pandas? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    import pandas as pd from itertools import combinations, product, permutations MH_P= ["Maria Herrera"] OP_P= ["Oscar ... i solve it? Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    I am trying to groupby a column and compute value counts on another column. import pandas as pd dftest = pd. ... Amt, already exists Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    I'm starting with input data like this df1 = pandas.DataFrame( { "Name" : ["Alice", "Bob", "Mallory", ... Any hints would be welcome. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I'm trying to get the number of rows of dataframe df with Pandas, and here is my code. Method 1: total_rows ... What am I doing wrong? Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    How do I get the index column name in python pandas? Here's an example dataframe: Index Title Column 1 Apples 1 ... how to do this? Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    I have a dataset |category| cat a cat b cat a I'd like to be able to return something like (showing unique values ... cat a 2 cat b 1 Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    I want to select rows from a DataFrame based on values in some column in pandas, How can I do it? I ... WHERE column_name = some_value Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    I created a dataframe and column labels in pandas and I need to edit in order to replace the original column ... names. Please help? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    I want to bind two data frames with different set of columns and I also want to retain all the columns that fails to ... do that in R? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    Can anyone tell me what is test size in Scikit learn? Select the correct answer from above options...
asked Jan 10, 2022 in Education by JackTerrance
0 votes
    I want to encode a 1-D numpy array: x = array([1,0,3]) As a 2-D 1-hot array y = array([ ... some faster technique other than looping. Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    I have code that at one place ends up with a list of data frames which I really want to convert ... starting with (this is grossly simplified for illustration): listOfDataFrames...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    What is the right amount of data to allocate for training, validation, and test sets?...
asked Mar 11, 2021 in Technology by JackTerrance
...