# Dynamiczne dopasowanie czasu (DTW) z najbliższym sąsiadem

EN: **Dynamic time warping with nearest-neighbour classification** · id `dtwknn` · aliases: DTW nearest-neighbour classification, DTW-1NN, elastic-distance classification

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [Uczenie maszynowe](https://aiatlasgraph.com/t/ml.md) › [Szeregi czasowe: prognozy, anomalie i klasyfikacja](https://aiatlasgraph.com/t/timeseries.md) › [Klasyfikacja szeregów czasowych](https://aiatlasgraph.com/t/tsclassification.md) › Dynamiczne dopasowanie czasu (DTW) z najbliższym sąsiadem

## Description

- PL: Elastyczna miara odległości wyrównująca szeregi nieliniowo w czasie, klasycznie łączona z klasyfikatorem najbliższego sąsiada.
- EN: An elastic distance aligning series non-linearly in time, classically paired with a nearest-neighbour classifier.

## In one sentence

- PL: Porównywanie dwóch zapisów o podobnym kształcie, ale innym tempie, przez elastyczne rozciąganie jednego względem drugiego.
- EN: Comparing two records with a similar shape but different pace by elastically stretching one against the other.

## Problem it solves

- PL: Ten sam gest albo słowo raz trwa krócej, raz dłużej, więc porównanie punkt po punkcie uznaje je za różne.
- EN: The same gesture or word sometimes takes less time and sometimes more, so point-by-point comparison treats them as different.

## What it does

- PL: Jak dopasowanie dwóch nagrań tej samej melodii granej w innym tempie: wyrównuje fragmenty, a potem wybiera klasę najbardziej podobnego wzorca.
- EN: Like aligning two recordings of one tune played at different speeds: it lines up fragments, then takes the class of the closest pattern.

## Everyday example

- PL: Aplikacja rozpoznaje gest narysowany palcem w powietrzu, porównując go z kilkoma zapisanymi wzorcami, nawet gdy ruch był wolniejszy.
- EN: An app recognises a gesture drawn in the air by comparing it with a few stored patterns, even when the movement was slower.

## This concerns you if you…

- PL: masz niewiele przykładów każdej klasy
- PL: twoje sygnały różnią się tempem przebiegu
- PL: chcesz prostego, łatwego do wyjaśnienia klasyfikatora
- EN: have few examples of each class
- EN: your signals differ in pace
- EN: want a simple, easily explained classifier

## Keywords

Sakoe-Chiba band · LB_Keogh · elastic ensemble · Proximity Forest · tslearn · dtaidistance · DTW barycenter averaging

## How it works

- PL: Programowanie dynamiczne znajduje ścieżkę wyrównania minimalizującą sumaryczną odległość między punktami obu serii, a okno, np. Sakoe–Chiby, ogranicza dopuszczalne przesunięcie. Nowy szereg dostaje klasę najbliższego wzorca. Zespoły elastycznych odległości poprawiają dokładność kosztem czasu.
- EN: Dynamic programming finds the alignment path minimising the total distance between points of both series, with a window such as Sakoe–Chiba limiting allowed shifts. A new series takes the class of its nearest pattern. Ensembles of elastic distances improve accuracy at a time cost.

## Limits

- PL: Koszt rośnie kwadratowo z długością serii, a porównanie z każdym wzorcem jest wolne dla dużych zbiorów. Wynik zależy od szerokości okna i normalizacji; w porównaniach ustępuje nowszym metodom.
- EN: Cost grows quadratically with series length, and comparing against every pattern is slow on large datasets. Results depend on window width and normalisation; in comparisons it trails newer methods.

## Key terms

- PL: **ścieżka wyrównania**: Dopasowanie punktów jednej serii do punktów drugiej.
- PL: **okno Sakoe–Chiby**: Ograniczenie, jak daleko dopasowane punkty mogą być przesunięte.
- PL: **1-NN**: Przypisanie klasy najbliższego znanego przykładu.
- EN: **warping path**: Matching of points in one series to points in the other.
- EN: **Sakoe–Chiba band**: A limit on how far matched points may be shifted.
- EN: **1-NN**: Assigning the class of the nearest known example.

## Know first

- [Metoda k najbliższych sąsiadów (k-NN) (k-nearest neighbours)](https://aiatlasgraph.com/t/knn.md)

## Sources

- [Bake off redux: a review and experimental evaluation of recent time series classification algorithms](<https://arxiv.org/html/2304.13029v3>) `middlehurst-bakeoff-redux-2024` · by Matthew Middlehurst, Patrick Schäfer, Anthony Bagnall

---

AI Atlas revision 126 (2026-11-03) · HTML: https://aiatlasgraph.com/t/dtwknn · index: https://aiatlasgraph.com/llms.txt · everything: https://aiatlasgraph.com/llms-full.txt · updated 2026-11-03
