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
1,080 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 19, 2020 by MD
• 95,460 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
890 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,490 points
926 views
0 votes
2 answers
+1 vote
2 answers

ValueError: Found input variables with inconsistent numbers of samples: [1, 1000]

Hi@akhtar, Here you used x as your feature ...READ MORE

answered Apr 14, 2020 in Machine Learning by MD
• 95,460 points

edited Aug 11, 2021 by Soumya 57,910 views
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,460 points
5,301 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP