Learn how to split data for machine learning in scikit-learn. Explore train_test_split, stratified splitting and cross-validation with Iris and California Housing.

In this episode:
• Training and test splits
• Stratified splitting and cross-validation
• Iris and California Housing examples

Chapters:
00:00 Splitting Data
01:15 Why Splitting Data?
02:45 What is Splitting Data?
05:26 Demo
12:33 Practice
15:53 Challenge

This is Day 48 of the 90-day AI and Python course on DailyAIWizard.
Full course playlist: https://www.dailymotion.com/playlist/x9qwfu
Previous: Day 47: Data Preprocessing in scikit-learn
https://www.dailymotion.com/video/x9q1gh4
Next: Day 49: Model Evaluation: Accuracy and Other Metrics
https://www.dailymotion.com/video/x9r524u

Links from this episode:
https://python.org
https://code.visualstudio.com
https://dailyaiwizard.com
https://discord.com/channels/1397945816349675600/1397945819260391521
https://x.com/dailyaiwizard
https://www.instagram.com/dailyaiwizard

Hosted by Oliver Bodemer. Presented with AI-generated tutor avatars: Anastasia, Sophia, Irene, Ethan, Victoria.
Channel: https://www.dailymotion.com/DailyAIWizard
YouTube: https://youtube.com/@dailyaiwizard

#TrainTestSplit #ScikitLearn #DailyAIWizard

Category

🤖
Tech
Transcript
00:00Hey, gorgeous wizards. Anastasia here, your main moderator, ready to dazzle you on day 48 of Daily AI Wizards Python for AI series.
00:08With Isabella on vacation, Irene's joining us. After pre-processing in day 47, we're splitting data for training and testing to make AI models shine.
00:17Let's dive into this sexy splitting adventure and code the future wizards.
00:21Hello, brilliant wizards. I'm Irene, thrilled to step in for Isabella and explore Scikit-Learn's data splitting techniques.
00:28Our demos will make your AI data prep sparkle with train test splits and more.
00:35Yo, wizards. Ethan's here, dropping spicy splitting code with a wink for Sophia.
00:41Train slash test splits and cross-validation are gonna pop. Let's crank this AI party to 11.
00:47Sophia here, Ethan, and your charms got me blushing. I'm pumped to lead our demos and make data splitting sizzle.
00:55Let's divide and conquer AI data, wizards.
00:59Victoria here, darlings. I'll sprinkle flirty tips to keep your splitting learning hot.
01:05Ready to split data like AI superstars? Let's dive in, wizards.
01:15Wizards, data splitting in Scikit-Learn is crucial for AI.
01:18It separates data into training and testing sets to prevent overfitting and ensure accurate model evaluation.
01:26Our demos will showcase splitting techniques like train test split and cross-validation for robust AI models.
01:34Oh, Irene, splitting's stealing my heart.
01:36It keeps AI models fair and sexy by balancing training and testing data.
01:40Get ready to divide data, wizards, and prep for day 49's metrics.
01:45Wizards, today we're seducing you with Scikit-Learn's data splitting magic.
01:49You'll master train test split, stratified splitting, cross-validation, and evaluation,
01:54with spicy demos to make you swoon.
01:56Our complex challenge will ignite your AI passion.
01:59Sophia's leading demos with fiery energy, Ethan's dropping hilarious code explanations,
02:05and Victoria's adding flirty tips.
02:07You'll master splitting for AI and be ready for day 49's metrics.
02:12Shine on, wizards.
02:13Wizards, meet your day 48 dream team.
02:16Anastasia's our main moderator, guiding with flirty charm.
02:20And I'm stepping in for Isabella with warmth.
02:24Ethan's our code comedian, flirting with Sophia while explaining splitting techniques.
02:30Oh, Irene, you're a gem.
02:32Sophia's leading demos with passion, Ethan's stealing my heart with code,
02:36and Victoria's tossing flirty tips.
02:38We're here to make you splitting superstars, wizards.
02:40Wizards, data splitting is your AI test crush, darling.
02:48It divides data into training and testing sets for fair model evaluation, preventing overfitting.
02:53We'll show its seductive powers in our demos.
02:56Anastasia, you make splitting sound so hot.
02:59How does it ensure fair AI models, love?
03:03Oh, Victoria, you tease.
03:04Splitting keeps training and testing data separate, ensuring unbiased AI predictions.
03:09Try it in our demos, wizards, and feel the balance.
03:12Yo, wizards, train underscore test underscore split, x, y, test underscore size equals 0.3,
03:19splits data like a hot dance for Sophia, dividing it for AI training and testing.
03:24It's a split party, let's drop this code beat.
03:28You're splitting my heart, Ethan.
03:31Wizards, train underscore test underscore split divides data for AI models, ensuring fair evaluation.
03:36Try it in our demo, it's like slicing your data treasures.
03:41Wizards, train underscore test underscore split, stratify equals y, stratify is like picking the best vibes for Sophia,
03:48balancing class distributions for AI.
03:51It's a stratified bash, let's keep this party rockin'.
03:55You're balancing my heart, Ethan.
03:58Wizards, stratified splitting ensures fair class representation in AI models.
04:02Try it in our demo, it's like harmonizing your data.
04:07Wizards, cross underscore val underscore score, model, x, y, cv equals 5,
04:13cross validates like a hot loop for Sophia, testing AI robustness across folds.
04:18It's a CV party, let's crank this code.
04:22You're validating my heart, Ethan.
04:25Wizards, cross validation ensures reliable AI model performance.
04:28Try it in our demo, it's like stress testing your data.
04:34Wizards, stratified k-fold, n underscore splits equals 5,
04:38stratifies folds like choosing the best moves for Sophia, balancing AI cross validation.
04:43It's a k-fold bash, let's drop this code beat.
04:47You're folding my heart, Ethan.
04:50Wizards, stratified k-fold ensures balanced AI evaluation.
04:54Try it in our demo, it's like perfecting your data splits.
04:57Wizards, pre-processing with standard scaler and splitting with train underscore test underscore split
05:04is a hot combo for Sophia, prepping AI data.
05:07It's a prep party, let's make it sizzle.
05:11You're prepping my heart, Ethan.
05:13Wizards, pre-processing and splitting power AI model training.
05:18Try it in our demo, it's like setting the AI stage.
05:26Wizards, it's demo time.
05:28And I'm thrilled to lead two complex splitting demos with Ciclet Learn.
05:31We'll load Iris and California housing, split with train underscore test underscore split
05:35and stratified k-fold, model, and visualize.
05:39Get your Python setup ready, and let's make AI shine.
05:43Oh Sophia, you're making my heart race.
05:46Ensure Python, VS Code, Ciclet Learn, Pandas, Matplotlib, and NumPy are set up,
05:50Wizards, and create splitting demo PI and housing, splitting demo PI.
05:56Ethan and Victoria will spice it up.
05:58Let's split cuties.
05:59Wizards, let's prep our demos to make them seamless.
06:03Open VS Code, create splitting underscore demo dot PY and housing underscore splitting underscore
06:08demo dot PY, and save them in a Python demo folder.
06:12Run pip install Ciclet Learn, Pandas, Matplotlib, NumPy, Seaborn, to ensure libraries are ready
06:16for splitting.
06:18Sophia, you make setup sound so dreamy.
06:21How do wizards install Ciclet Learn to split like pros, love?
06:25You're too sweet, Victoria.
06:28Run pip install Ciclet Learn, Pandas, Matplotlib, NumPy, Seaborn, in a terminal, and activate
06:33your virtual environment with source myint slash bin slash activate or myint backslash scripts
06:37backslash activate.
06:39Let's make these demos sparkle.
06:41Wizards, our first demo in splitting underscore demo dot PY loads iris, splits with train underscore
06:48test underscore split and stratified k fold, trains a random forest classifier, evaluates
06:53with accuracy and confusion matrix, and visualizes with a heat map.
06:57Let's run this and see AI splitting magic.
07:02Oh, Sophia, you're makin' this demo hot.
07:05Train underscore test underscore split and stratified k fold, split iris with swagger, plus a sexy
07:11heat map, total AI party.
07:14Wizards, train underscore test underscore split, x, y, test underscore size equals 0.3, splits iris
07:21like a hot dance for Sophia, dividing data for AI training and testing.
07:25It's a split party, let's drop this code beat.
07:30You're splitting my heart, Ethan.
07:33Wizards, train underscore test underscore split divides iris data for fair AI model evaluation.
07:39Try it in our demo, it's like slicing your data treasures.
07:44Wizards, train underscore test underscore split, stratify equals y, stratifies iris like picking
07:50the best vibes for Sophia, balancing class distributions for AI.
07:53It's a stratified bash, let's keep this party rockin'.
07:58You're balancing my heart, Ethan.
08:01Wizards, stratified splitting ensures fair class representation in iris models.
08:07Try it in our demo, it's like harmonizing your data.
08:10Wizards, cross underscore val underscore score, model, x, y, cv equals 5, cross validates iris
08:18like a hot loop for Sophia, testing AI robustness across folds.
08:23It's a CV party, let's crank this code.
08:26You're validating my heart, Ethan.
08:30Wizards, cross validation ensures reliable iris model performance.
08:35Try it in our demo, it's like stress testing your data for AI.
08:38Wizards, stratified k-fold, n underscore splits equals 5, stratifies folds for iris like choosing
08:46the best moves for Sophia, balancing AI cross-validation.
08:50It's a k-fold bash, let's drop this code beat.
08:54You're folding my heart, Ethan.
08:57Wizards, stratified k-fold ensures balanced iris evaluation.
09:02Try it in our demo, it's like perfecting your data splits for AI.
09:06Wizards, our second demo in housing underscore splitting underscore demo dot py loads California
09:13housing, splits with train underscore test underscore split and stratified k-fold using
09:17bin targets, trains a regression model, evaluates with msc slash r superscript 2, and visualizes
09:23residuals.
09:25Let's run this and see AI magic.
09:27Sophia, you're makin' this demo sizzle.
09:32Train underscore test underscore split and stratified k-fold, split housing with swagger,
09:37plus a sexy residuals plot, total AI party.
09:41Wizards, train underscore test underscore split, x, y, stratify equals y underscore bend,
09:47splits housing like a hot dance for Sophia, balancing regression data with bin targets.
09:52It's a split party, let's rock it.
09:54You're splitting my heart, Ethan.
09:58Wizards, splitting housing with bin targets ensures fair AI evaluation.
10:04Try it in our demo, it's like slicing data treasures.
10:08Wizards, np.digitize, y, np.quantile, y, 0, 0.25, 0.5, 0.75, 1.0,
10:19bins housing targets like picking hot vibes for Sophia, enabling stratified splits.
10:24It's a binning bash.
10:27You're binning my heart, Ethan.
10:30Wizards, binning enables stratified splitting for housing regression.
10:34Try it in our demo, it's like balancing your data.
10:39Wizards, stratified k-fold, for bin housing targets is a hot move for Sophia,
10:44balancing AI cross-validation for regression.
10:47It's a k-fold party, let's crank it.
10:49You're folding my heart, Ethan.
10:53Wizards, stratified k-fold ensures balanced housing evaluation.
10:58Try it in our demo, it's like perfecting regression splits.
11:03Wizards, linear regression, .fit, x underscore train, y underscore train,
11:08trains housing like a dance for Sophia, predicting prices with split data.
11:12It's a modeling party, let's make it sizzle.
11:15You're modeling my heart, Ethan.
11:19Wizards, modeling split housing data builds AI regression models.
11:24Try it in our demo, it's like crafting AI predictions.
11:29Wizards, plt.scatter, y underscore test, residuals,
11:33shows housing residuals like a visual serenade for Sophia, checking AI model fit.
11:38It's a residuals party, let's drop this plot.
11:41You're visualizing my heart, Ethan.
11:45Wizards, residuals visualization confirms housing model quality.
11:50Try it in our demo, it's like painting AI accuracy.
11:55Wizards, let's run splitting underscore demo dot py and housing underscore splitting underscore demo dot py.
12:02In VS Code's terminal, type python3 splitting underscore demo dot py or housing underscore splitting underscore demo dot py and hit enter.
12:11You'll see splits, models, and visuals, showcasing your AI mastery.
12:17Sophia, you make running demos sound so tempting.
12:20Outputs show balanced splits and sexy plots, pure AI seduction.
12:25Run them and share your results, Wizards.
12:27Wizards, pandas from day 44 with splitting is a hot combo for Sophia.
12:37PD data frame, iris.data, preps data for train slash test splits, coding fireworks light up the AI sky.
12:45You're prepping my heart, Ethan.
12:48Wizards, pandas power splitting for AI models.
12:52Try it in our challenge, it's like crafting data for AI success.
12:56Wizards, day 39's number py with splitting is a triple threat for Sophia.
13:03NP.array, x, powers AI data for splits, coding fireworks make this party epic.
13:09You're powering my heart, Ethan.
13:12Wizards, number py supports splitting for AI models.
13:17Try it in our challenge, it's like fueling AI with math magic.
13:20Wizards, plt.scatter, y underscore test, residuals, is a visual serenade for Sophia, showing split AI results.
13:30It's a plot party, let's make these visuals pop.
13:34You're plotting my heart, Ethan.
13:37Wizards, matplotlib visualizes split data performance.
13:41Try it in our demo, it's like painting AI accuracy.
13:45Wizards, seaborne from day 42 with splitting is a sexy duet for Sophia.
13:51SNS.heatmap, cm, shows AI confusion matrices, coding fireworks light up the screen.
13:59You're raising my visuals, Ethan.
14:02Wizards, seaborne enhances splitting visualizations.
14:06Try it in our challenge, it's like styling your AI results.
14:09Wizards, day 47's pre-processing with splitting is a hot combo for Sophia.
14:16Standard scaler, and train underscore test underscore split, prep AI data, coding fireworks make this epic.
14:23You're prepping my heart, Ethan.
14:26Wizards, pre-processing and splitting power AI models.
14:31Try it in our challenge, it's like crafting perfect AI data.
14:34Wizards, day 40 success datasets with splitting are a hot combo for Sophia.
14:41Train underscore test underscore split, splits iris and housing, coding fireworks fuel AI models.
14:48You're splitting my heart, Ethan.
14:51Wizards, splitting datasets powers AI training.
14:55Try it in our challenge, it's like dividing data for AI success.
14:58Wizards, optimize splitting with stratify equals Y for balanced classes and random state for reproducibility.
15:08Use cross-validation for robust evaluation.
15:12Clean splitting ensures fair and accurate AI models.
15:16Optimize splitting so sexy, Irene.
15:18Clear practices make AI models irresistible and fair.
15:22Practice for day 49's metrics, wizards, and keep those splits sizzling.
15:25Wizards, splitting's critical in AI pipelines, darling.
15:29It ensures fair training and testing for accurate models.
15:32Your day 48 skills make AI irresistible.
15:35Split like pros.
15:37Splitting powers AI pipelines, wizards.
15:40It separates data for robust model training and evaluation.
15:44Your skills are ready for real projects.
15:46Prep for day 49's metrics.
15:53Wizards, here's your challenge.
15:54Create AI splitting PY to load California housing.
15:58Split with train test, split, and stratified K-fold.
16:01Bend targets.
16:02Train a linear regression model.
16:04Evaluate with MSER2.
16:06And visualize residuals with seaborne scatterplot and annotations.
16:10Run with python3aiisplitting.pi and share on Instagram, darlings.
16:15This is thrilling, wizards.
16:17Try train test split, stratified K-fold, and SNS scatterplot for residuals.
16:23Show us your results at Daily AI Wizard.
16:26It's an AI splitting spell.
16:28Prep for day 49's metrics.
16:31Wizards, hit subscribe.
16:33Like this video and share your AISplitting.pi output in the comments.
16:37Got splitting questions?
16:38We're here to help.
16:39Join our Discord or X to connect and grow.
16:43Our community's a total heartthrob, wizards.
16:46Post your code, flirt with tips, or share wins on Discord, X, or Daily AI Wizard on Instagram.
16:53Subscribe for day 49's metrics, cuties.
16:56Wizards, you've stolen my heart with your splitting skills.
16:59You're splitting demo PY and housing splitting demo pie.
17:02Prove your AI data superstars.
17:05Keep flirting with code for day 49's metrics, darlings.
17:08I'm so proud, wizards.
17:10You've mastered splitting for AI, ensuring fair models.
17:14Share your AISplitting.py on at Daily AI Wizard.
17:18Subscribe for day 49 and join our Discord or X.
17:22Code the future, wizards.
17:25You nailed splitting, wizards.
17:27Your data's hot, Sophia.
17:29Get hyped for day 49's metrics.
17:32Let's keep this flirty AI party rockin' with more code.
17:36Wizards, you're phenomenal.
17:39These demos were a blast, Ethan, and your splitting skills are fire.
17:43Share your AI underscore splitting dot PY and subscribe for day 49.
17:48Code the future, wizards.
17:51You've swept me off my feet, wizards.
17:53Your splitting skills are pure AI seduction.
17:57Let's flirt with metrics in day 49.
17:59Keep coding sexy.

Recommended