Prepare recipes and their exports
Clean a dataset as a list of steps that never touches the original, then export the same recipe to SQL, pandas or dplyr.
What runs in CodeSplash
- Power transformation (Box–Cox / Yeo–Johnson) Verified in Python and R
You will be able to
- Explain why a recipe leaves the original data untouched
- Add suggested fixes and read a step's before-and-after
- Apply a recipe to a new dataset and export it as code
Cleaning you can read back
ReadMost data cleaning disappears: a formula here, a deleted row there, nothing to show what changed. A recipeRecipeAn ordered list of data-preparation steps that replays on new versions and exports to SQL, pandas and dplyr. in Prepare (⌘3) is a list of steps instead. Each step records what it did, and the source dataset is never modified.
Because the steps are data, you can reorder them, turn one off, compare two versions, and rerun the lot on next month's file.
Messy customer listShould a recipe fix this by itself?
PredictPredict first
Add all safe fixes adds the suggestions that cannot change what your data means. Which of these do you expect it to add without asking?
Reveal
Trimming spaces. It only tidies a value. Deciding that -99 means unknown is a claim about the data, even though it is probably right, so that one stays your decision: you read it and add it yourself.
Start a recipe
In the appIn Prepare, press New recipe, pick the messy customer list and create it. Open Suggested fixes on the right: CodeSplash profiled the data and drafted steps for what it found, each with Why it matters.
Add the safe ones, then add the sentinel fix for age yourself.
Select any step. The workspace shows what that step changes, so you can catch a mistake before it reaches the next one.
Learned values
ExploreSome steps learn from the data: a median to fill gaps, a list of category levels, the bounds for capping. Add a Fill missing values step on spend_30d with the median and read the value it learned.
Those values are stored in the recipe. If your data changes, Refit learned values recomputes them on all rows. That difference matters for modeling: learned values fitted on all your data leak information into a test set, which is why the scikit-learn and recipes exports refit on training data.
Apply, then export
In the appApply recipe runs every step on all rows and writes the output as a new dataset or the next version of the recipe's output, recording where it came from. Your source stays where it was.
Code gives you the same recipe five ways: SQL, pandas, dplyr, scikit-learn and recipes. The first three reproduce the app's output, with learned values written in. Copy one, or use Open as script.
Column lineage shows where every output column came from, and History compares and restores versions.
Check your understanding
CheckpointCheck yourself
You apply a recipe that removes 12 duplicate customers. What happens to the source dataset?
Show the answer
Answer: b
Source data is never changed. That is what lets you see exactly what a recipe did and go back when it was wrong.
Check yourself
You are building a model and want a preprocessing pipeline that does not leak test rows into its learned values. Which export fits?
Show the answer
Answer: c
SQL, pandas and dplyr write the learned values in, which reproduces the app. A pipeline you fit on training data recomputes them, which is what honest validation needs.
Where would this save you?
ReflectThink of the last spreadsheet you cleaned by hand. Could you redo it next month from memory? Which step would you most want written down?
A cleaned column is often ready for a transform test. For example, a skewed measure might suit a power transform:
Recap
Recap- A recipe is a readable list of steps; the source is never changed.
- Suggested fixes separate safe tidying from decisions about meaning.
- Apply writes a new version; Code exports the same recipe to SQL, pandas, dplyr, scikit-learn or recipes.
Concepts in this lesson