Machine Learning | Train Test Split in Cross Validation using Pandas and Numpy
How to do Train Test Split using
1. sklearn.model_selection.train_test_split
2. pandas
3. numpy
4. train test split in a sequential order
'''
Method No 2 using Pandas
import pandas as pd
import numpy as np
from sklearn.datasets import make_blobs
X, y = make_blobs(n_samples=10, random_state=1)
df = pd.DataFrame(X)
df.sample(frac=0.5)
df.sample(frac=0.6)
df.sample(frac=0.8)
train train Split -- 60 : 40
np.split(df.sample(frac=1),[6])
np.split(df.sample(frac=1),[7]) # 70:30
np.split(df.sample(frac=1),[6,8])
train, test = np.split(df.sample(frac=1),[int(0.6*len(df))])
train train Split -- 70 : 30
train, test = np.split(df.sample(frac=1),[int(0.7*len(df))])
train validate test split -- 60 : 20 : 20
train,val, test = np.split(df.sample(frac=1),[int(0.6*len(df)),
int(0.8*len(df))])
train validate test split -- 50 : 30 : 20
train,val, test = np.split(df.sample(frac=1),[int(0.5*len(df)),
int(0.8*len(df))])
All Playlist of this youtube channel
====================================
1. Data Preprocessing in Machine Learning
• Data Preprocessing in Machine Learnin...
2. Confusion Matrix in Machine Learning, ML, AI
• Confusion Matrix in Machine Learning,...
3. Anaconda, Python Installation, Spyder, Jupyter Notebook, PyCharm, Graphviz
• Anaconda | Python Installation | Spyd...
4. Cross Validation, Sampling, train test split in Machine Learning
• Cross Validation | Sampling | train t...
5. Drop and Delete Operations in Python Pandas
• Drop and Delete Operations in Python ...
6. Matrices and Vectors with python
• Matrices and Vectors with python
7. Detect Outliers in Machine Learning
• Detect Outliers in Machine Learning
8. TimeSeries preprocessing in Machine Learning
• TimeSeries preprocessing in Machine L...
9. Handling Missing Values in Machine Learning
• Handling Missing Values in Machine Le...
10. Dummy Encoding Encoding in Machine Learning
• Label Encoding, One hot Encoding, Dum...
11. Data Visualisation with Python, Seaborn, Matplotlib
• Data Visualisation with Python, Matpl...
12. Feature Scaling in Machine Learning
• Feature Scaling in Machine Learning
13. Python 3 basics for Beginner
• Python | Python 3 Basics | Python for...
14. Statistics with Python
• Statistics with Python
15. Sklearn Scikit Learn Machine Learning
• Sklearn Scikit Learn Machine Learning
16. Python Pandas Dataframe Operations
• Python Pandas Dataframe Operations
17. Linear Regression, Supervised Machine Learning
• Linear Regression | Supervised Machin...
18 Interiew Questions
• Interview Question for Machine Learni...
19. Jupyter Notebook Operations
• Jupyter and Spyder Notebook Operation...