Train-test split with 20 of data set aside - ML

0 votes
I have an assignment of Making a train -test split with 20% of the data set aside for testing. How do I do that using python?
May 24, 2019 in Machine Learning by Kim
218 views

1 answer to this question.

0 votes

Hi@Kim,

You can use the train_test_split function to do this. You can use the below code in your program.

from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.2,random_state=42)

I hope this will help.

answered Jul 18, 2020 by MD
• 95,220 points

Related Questions In Machine Learning

0 votes
1 answer
+1 vote
0 answers

text mining new set of data in production environment expect training feature

Hi, I have trained a model based on ...READ MORE

Nov 28, 2019 in Machine Learning by MANOJ
• 130 points
158 views
0 votes
1 answer
+1 vote
1 answer

Machine Learning and Python Code

You can create an array called actualScore ...READ MORE

answered Dec 13, 2018 in Data Analytics by Shubham
• 13,480 points
207 views
0 votes
2 answers
+1 vote
1 answer
0 votes
1 answer

Found input variables with inconsistent numbers of samples:

Hi@sagar, You have converted your Dataframe into an ...READ MORE

answered Jul 13, 2020 in Machine Learning by MD
• 95,220 points
3,036 views