Predictive Hacks

Train and Test Dataset with Pandas

You can easily create a train and test dataset with Pandas as follows:

# use a random state to be reproducible
# 80% train and 20% for test

train=df.sample(frac=0.8,random_state=5) 
test=df.drop(train.index)



# if you want an absolute number for the train
train=df.sample(n=1000000,random_state=5) 

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore

Python

Image Captioning with HuggingFace

Image captioning with AI is a fascinating application of artificial intelligence (AI) that involves generating textual descriptions for images automatically.

Python

Intro to Chatbots with HuggingFace

In this tutorial, we will show you how to use the Transformers library from HuggingFace to build chatbot pipelines. Let’s