{"canonical_url":"https://engineer.company/glossary/machine-learning/","content_markdown":"# Machine learning\n\n## What it is\n\nMachine learning is the practice of building software that learns a task from\nexamples instead of from rules a programmer writes out. You give it many cases\nwhere the answer is already known, it finds a relationship between the inputs\nand the answers, and it uses that relationship to predict the answer for each\nnew case. The name is older than nearly all the software that now uses it: A. L.\nSamuel put it in the title of a study of the game of checkers that the IBM\nJournal of Research and Development printed in July 1959.\n\nThe vocabulary is easiest to pin down with scikit-learn, the open source Python\nlibrary whose documentation this article follows. The examples sit in a table.\nEach row is one sample, such as an invoice, a customer or a sensor reading, and\neach column is a feature, a number that describes the sample. The answer you\nwant the software to learn is the target. In scikit-learn's terms the thing that\nlearns is an estimator. Every estimator has a `fit` method that learns from the\nrows you show it. Predictive estimators use `predict` to give answers for new\nrows; transformers use `transform` to produce a transformed sample table.\n\nTwo families cover most of the work. In supervised learning every training row\ncomes with its target. When the target is a category, such as paid on time or\npaid late, the task is classification; when it is a quantity, such as the number\nof days until payment, it is regression. In unsupervised learning there is no\ntarget at all, and the software looks for structure by itself, for instance by\ngrouping customers who behave alike. The scikit-learn documentation gives each\nfamily a chapter of its own, followed by one on model selection and evaluation,\nwhich is where most of the practical difficulty lives.\n\nWhat machine learning is not, at least in this sense, is a word for any software\nthat seems clever. A rule that flags every invoice above a fixed amount was\nwritten by a person and does exactly what it says. A model that flags invoices\nhas derived its rule from past invoices, so it can be wrong in ways nobody wrote\ndown, and its behaviour changes whenever the data it learns from changes.\n\n## Why it matters\n\nSome tasks are far easier to show by example than to describe. Nobody can write\na complete rule for which invoices will be paid late, but most companies hold\nyears of invoices with the outcome recorded. Machine learning turns that record\ninto a working rule, and it can do the same for many such questions at once,\nwhich is why it has moved from research into ordinary business software.\n\nThe price is that the data now does the job the code used to do. If the history\nholds mistakes, duplicates or gaps, the model learns those as well, and nothing\nin the code shows it. D. Sculley and nine colleagues at Google described what\nfollows in *Hidden Technical Debt in Machine Learning Systems*, a paper in the\nproceedings of the 2015 NIPS conference. Their first figure draws the learning\ncode as a small black box in the middle of a much larger system, and the caption\ncalls the infrastructure around it vast and complex. In one passage they\nestimate that a mature system may end up as at most 5% machine learning code and\nat least 95% glue code that moves data in and out of general-purpose packages.\n\nThey also argue that a dependency on data costs more than a dependency on code.\nCompilers and build systems trace which code depends on which, while tools that\ndo the same for data are far less common, so a column can change meaning without\nanything noticing. And they name a principle, CACE, for \"Changing Anything\nChanges Everything\": shift the distribution of one input and the way the model\nuses every other input may shift with it.\n\nSo a model is cheap to make and expensive to keep. The work that decides whether\nit helps is mostly about data: where it comes from, whether each customer\nappears once or three times, whether the recorded outcome is right, and who will\nnotice when a system upstream starts sending something different.\n\n## What it looks like in practice\n\nTake a company that wants to know, on the day it issues an invoice, which\ninvoices are likely to be paid late, so that someone can call those customers\nbefore the due date rather than after it. An export holds one row per past\ninvoice, sorted by issue date, with four columns that were known on the day each\ninvoice went out: the amount, the days of credit granted, how many invoices the\ncustomer received in the year before, and how many of those were paid late. A\nfifth column records what happened: 1 if the invoice was paid late, 0 if it was\npaid on time.\n\nThe script below was written for this article and checked line by line against\nthe scikit-learn 1.9.1 and NumPy 2.5 documentation in October 2026. It trains a\nmodel on the older invoices and tests it on the newest quarter:\n\n```python\n# invoices.csv: one row per invoice, sorted by issue date, numbers only.\n# The last column is 1 if the invoice was paid late, 0 if on time.\nimport numpy as np\nfrom sklearn.dummy import DummyClassifier\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.metrics import balanced_accuracy_score\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.pipeline import make_pipeline\nfrom sklearn.preprocessing import StandardScaler\n\ndata = np.loadtxt(\"invoices.csv\", delimiter=\",\", skiprows=1)\nX, y = data[:, :-1], data[:, -1].astype(int)\n\n# Hold the newest quarter back: nothing learns from it.\nX_old, X_new, y_old, y_new = train_test_split(\n    X, y, test_size=0.25, shuffle=False\n)\n\nmodel = make_pipeline(StandardScaler(), LogisticRegression())\nbaseline = DummyClassifier(strategy=\"most_frequent\")\nfor name, candidate in [(\"model\", model), (\"baseline\", baseline)]:\n    candidate.fit(X_old, y_old)\n    score = balanced_accuracy_score(y_new, candidate.predict(X_new))\n    print(name, round(score, 3))\n```\n\nFour choices in it matter more than the choice of algorithm.\n\n**The newest quarter is set aside before anything learns.** With\n`shuffle=False`, `train_test_split` keeps the rows in order and puts the last\nquarter in the test set, so the model learns from older invoices and is judged\non newer ones, which is how it will be used. With the default, `shuffle=True`,\nthe split would be random, and the model would partly be tested on invoices\nolder than some it learned from.\n\n**The scaling sits inside the pipeline.** `StandardScaler` removes each\nfeature's mean and scales it to unit variance. Because `make_pipeline` chains it\nto the classifier, the mean and variance come from the training rows alone, and\nnothing about the newest quarter seeps into the model.\n\n**The score is balanced accuracy.** It averages, over the two classes, the share\nof each class the model got right: the late invoices it caught and the punctual\nones it recognised. If one invoice in ten is paid late, plain accuracy rewards a\nmodel for answering \"on time\" every time. Balanced accuracy does not.\n\n**The model has to beat a baseline.** `DummyClassifier` with\n`strategy=\"most_frequent\"` ignores the features and always gives the commonest\nanswer. On balanced accuracy it scores 0.5 with two classes, since it gets every\npunctual invoice right and every late one wrong. A model that does not clearly\nbeat it has learned nothing useful, however good its plain accuracy looks.\n\nNone of this rescues a model from bad rows. If one customer exists as three\nrecords, the count of that customer's late invoices is split three ways, and the\nmodel learns from a history that never happened. Our page on\n[AI Data Readiness](/services/ai-data/) is about that groundwork: a single\nrecord per customer, each person able to see only what they should, and any\nanswer traceable to the data behind it. For a model, the last of those is what\nlets you walk back from a strange prediction to the rows that produced it.\n\n## Where it goes wrong\n\n**Information from the future gets into training.** The scikit-learn guide to\ncommon pitfalls calls this data leakage: building the model with information\nthat will not exist when it makes a prediction. In the invoice example, the\ntempting extra column is the number of reminders sent, which predicts lateness\nsuperbly because reminders go out only once an invoice is overdue. The same leak\nhappens more quietly when a scaler or an imputer is fitted on every row before\nthe split, and the guide's rule is never to call `fit` on the test data. The fix\nis to write down, for each column, the moment its value becomes known, to split\nfirst, and to keep every preprocessing step inside the pipeline so that it is\nfitted on training rows only.\n\n**The model is judged on what it has already seen.** A model that only repeated\nthe targets it was trained on would score perfectly on its own training rows and\nbe useless on anything new; the cross-validation guide calls this overfitting. A\nsubtler form is to try many settings and keep whichever scores best on the\nheld-out rows, which lets knowledge of those rows leak into the choice. The fix\nis to compare settings with cross-validation on the training part, where the\nrows are cut into several folds and each fold takes a turn as the test set, and\nto look at the held-out rows once, at the end.\n\n**A high accuracy that a constant could match.** When one class is rare,\naccuracy is dominated by the common one, and the guide warns that with rare\nclasses, as in fraud detection, a fold can end up with no example of the rare\nclass at all. Report balanced accuracy or another per-class measure, compare\nwith a `DummyClassifier`, and use stratified folds, which keep the class\nproportions roughly equal in every fold. `cross_val_score` uses them by default\nfor a classifier when you pass it a number of folds.\n\n**A random split for data that moves over time.** The cross-validation guide\nnotes that the assumption of independent, identically distributed samples rarely\nholds in practice, and that data ordered in time should be tested on\nobservations later than the ones the model learned from. A random split lets the\nmodel peek at the future and reports a score it will not reach. Split by date,\nas the example does, and when cross-validating use a time-aware splitter such as\n`TimeSeriesSplit`, whose folds the guide says should each cover the same span of\ntime.\n\n**Preprocessing that differs between training and production.** If the model\nlearned from scaled features and the live system sends raw ones, the predictions\nare wrong and no error is raised. The pitfalls guide requires any transformation\nused in training to be applied to test data and to data in production alike.\nShip the fitted pipeline as one object, rather than a model plus a note on what\nto do to the data first.\n\n**The world changes after launch.** A model trained on last year's invoices\nassumes that customers still behave as they did then. Sculley and his co-authors\nsuggest tracking prediction bias: in a system that works as intended, the share\nof each predicted label should usually match the share actually observed, and a\ngap that opens between them is often the first sign that the world has moved.\nKeep that comparison running, retrain on recent data, and hold a frozen,\nversioned copy of any input signal another team owns, so that a well-meant\nchange upstream does not silently change your model.\n\n## Further reading\n\n- [User Guide](https://scikit-learn.org/stable/user_guide.html)\n  — scikit-learn's reference for supervised and unsupervised learning and for\n  model selection and evaluation, chapter by chapter.\n- [Getting Started](https://scikit-learn.org/stable/getting_started.html)\n  — the estimator interface in a few short examples: fitting and predicting,\n  transformers, pipelines and cross-validation.\n- [Common pitfalls and recommended practices](https://scikit-learn.org/stable/common_pitfalls.html)\n  — inconsistent preprocessing, data leakage and randomness, with the wrong way\n  and the right way side by side in code.\n- [Cross-validation: evaluating estimator performance](https://scikit-learn.org/stable/modules/cross_validation.html)\n  — why testing on training data misleads, and which splitting scheme suits\n  grouped, imbalanced or time-ordered data.\n- [Hidden Technical Debt in Machine Learning Systems](https://papers.nips.cc/paper_files/paper/2015/hash/86df7dcfd896fcaf2674f757a2463eba-Abstract.html)\n  — Sculley and colleagues at Google, NIPS 2015, on what running a model in\n  production costs beyond the model itself.\n\n\u003chttps://engineer.company/glossary/machine-learning/\u003e\n","date_modified":"2026-11-09T21:50:25Z","description":"How machine learning builds software from examples instead of rules, what a first model on business data looks like, and the mistakes that flatter it.","formats":{"gemtext":"https://engineer.company/glossary/machine-learning/index.gmi","gopher":"https://engineer.company/glossary/machine-learning/gophermap","html":"https://engineer.company/glossary/machine-learning/","json":"https://engineer.company/glossary/machine-learning/index.json","markdown":"https://engineer.company/glossary/machine-learning/index.md","pdf":"https://engineer.company/glossary/machine-learning/index.pdf"},"kind":"page","language":"en","title":"What is machine learning?","url":"https://engineer.company/glossary/machine-learning/","version":1}