diff --git a/.gitignore b/.gitignore index e5db262..b8dda68 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,6 @@ desktop.ini # Templates are always committed, even if a rule above matches them. !*.example + +# Trained models, rebuilt by ml/train.py from data/raw. +ml/models/ diff --git a/docs/results/2026-11-22-first-model/checks.txt b/docs/results/2026-11-22-first-model/checks.txt new file mode 100644 index 0000000..0585741 --- /dev/null +++ b/docs/results/2026-11-22-first-model/checks.txt @@ -0,0 +1,101 @@ +Windows per device and distance (5 s windows, 1 s step) +dist 0.5 1.0 1.5 2.0 2.5 3.0 3.5 +device +earpiece B class 55 55 55 54 54 55 52 +phone B 55 55 55 54 55 55 56 +phone B class 55 54 55 0 0 0 0 +phone C class 55 55 53 53 55 7 49 + +== Band, three classes == +all features leave one session out accuracy 62.9% balanced 60.8% +all features leave one device out accuracy 62.6% balanced 63.6% +BLE only (no spectrum) leave one session out accuracy 44.3% balanced 46.9% +BLE only (no spectrum) leave one device out accuracy 53.3% balanced 55.7% +spectrum only leave one session out accuracy 42.8% balanced 35.8% +spectrum only leave one device out accuracy 45.2% balanced 42.9% + +== Band without the 1.0 m and 2.0 m sessions (they sit on band edges) == +all features: accuracy 71.1% balanced 67.7% +predicted far mid near +true +far 355 82 1 +mid 156 61 1 +near 8 5 207 + +BLE only (no spectrum): accuracy 53.4% balanced 52.0% +predicted far mid near +true +far 251 186 1 +mid 208 9 1 +near 4 8 208 + +== Mid vs far only (chance is 50% balanced) == +all features leave one session out accuracy 70.0% balanced 70.1% +all features leave one device out accuracy 62.4% balanced 55.9% +BLE only (no spectrum) leave one session out accuracy 48.7% balanced 48.9% +BLE only (no spectrum) leave one device out accuracy 55.9% balanced 53.7% + +Mid vs far, BLE only, leave one session out: windows predicted per session +predicted far mid +device dist +earpiece B class 1.0 7 48 + 1.5 18 37 + 2.0 52 2 + 2.5 39 15 + 3.0 30 25 + 3.5 49 3 +phone B 1.0 0 55 + 1.5 33 22 + 2.0 41 13 + 2.5 17 38 + 3.0 22 33 + 3.5 14 42 +phone B class 1.0 14 40 + 1.5 52 3 +phone C class 1.0 0 55 + 1.5 44 9 + 2.0 52 1 + 2.5 8 47 + 3.0 0 7 + 3.5 41 8 + +Mid vs far, BLE only, one model per device (leave one session out) +earpiece B class: accuracy 60.0% balanced 60.0% (6 sessions) +phone B: accuracy 57.6% balanced 57.6% (6 sessions) +phone B class: only one band recorded, skipped +phone C class: accuracy 48.9% balanced 48.7% (6 sessions) + +== Spectrum by session, in recording order == +The nRF24 sees the whole room. If these move with the clock and not with distance, +the spectrum features describe the room's Wi-Fi traffic, not the test device. + minute device dist spec_active spec_mean_frac rssi_median +0 0 phone B 0.500 68.000 0.051 -63.500 +1 5 phone B 1.000 77.000 0.064 -67.000 +2 6 phone B 1.500 72.000 0.052 -78.000 +3 9 phone B 2.000 75.000 0.056 -78.000 +4 10 phone B 2.500 75.000 0.067 -77.500 +5 11 phone B 3.000 75.000 0.068 -79.000 +6 13 phone B 3.500 76.000 0.073 -79.000 +7 95 phone B class 0.500 31.000 0.017 -62.000 +8 97 phone B class 1.000 31.000 0.017 -74.000 +9 98 phone B class 1.500 32.000 0.016 -86.000 +10 120 phone C class 0.500 36.000 0.019 -65.000 +11 122 phone C class 1.000 36.000 0.020 -78.000 +12 124 phone C class 1.500 32.000 0.016 -95.000 +13 125 phone C class 2.000 31.000 0.016 -95.000 +14 127 phone C class 2.500 33.000 0.017 -98.000 +15 128 phone C class 3.000 36.000 0.022 -92.000 +16 130 phone C class 3.500 36.000 0.020 -99.000 +17 194 earpiece B class 0.500 38.000 0.021 -64.000 +18 196 earpiece B class 1.000 32.000 0.018 -73.500 +19 198 earpiece B class 1.500 28.000 0.017 -85.000 +20 199 earpiece B class 2.000 29.000 0.017 -78.000 +21 202 earpiece B class 2.500 51.500 0.035 -82.750 +22 203 earpiece B class 3.000 45.000 0.061 -77.500 +23 204 earpiece B class 3.500 45.000 0.022 -80.000 + +== Type (phone vs earpiece) == +all features leave one session out accuracy 100.0% balanced 100.0% +no manufacturer columns leave one session out accuracy 97.9% balanced 97.3% +BLE timing and RSSI only leave one session out accuracy 96.9% balanced 96.4% +Leave one device out is not possible for type: there is only one earpiece. diff --git a/docs/results/2026-11-22-first-model/confusion_band.csv b/docs/results/2026-11-22-first-model/confusion_band.csv new file mode 100644 index 0000000..ebd65e2 --- /dev/null +++ b/docs/results/2026-11-22-first-model/confusion_band.csv @@ -0,0 +1,4 @@ +,near,mid,far +near,98,121,1 +mid,85,317,196 +far,1,102,335 diff --git a/docs/results/2026-11-22-first-model/confusion_type.csv b/docs/results/2026-11-22-first-model/confusion_type.csv new file mode 100644 index 0000000..c2ae511 --- /dev/null +++ b/docs/results/2026-11-22-first-model/confusion_type.csv @@ -0,0 +1,3 @@ +,phone,earpiece +phone,876,0 +earpiece,0,380 diff --git a/docs/results/2026-11-22-first-model/make_checks.py b/docs/results/2026-11-22-first-model/make_checks.py new file mode 100644 index 0000000..897cee4 --- /dev/null +++ b/docs/results/2026-11-22-first-model/make_checks.py @@ -0,0 +1,189 @@ +"""Train and check the first device-type and distance-band models. + +Run from the repo root (needs the labelled sessions in data/raw/, which stay on the laptop): + python docs/results/2026-11-22-first-model/make_checks.py + +Writes next to this file: + train_output.md the standard ml.train report (5 grouped folds, whole sessions held out) + confusion_type.csv, confusion_band.csv + checks.txt the extra checks the report quotes (other splits, feature subsets) + rssi_by_distance.png window RSSI by distance, one panel per device +and saves the two models, trained on every session, to ml/models/ (gitignored). + +No hashed addresses are written: rows are grouped by device model and distance. +""" + +from __future__ import annotations + +import json +import sys +from pathlib import Path + +import joblib +import matplotlib + +matplotlib.use("Agg") +import matplotlib.pyplot as plt +import numpy as np +import pandas as pd +from sklearn.metrics import accuracy_score, balanced_accuracy_score +from sklearn.model_selection import LeaveOneGroupOut + +sys.path.insert(0, ".") +from ml.features import BLE_COLS, FEATURE_COLS, MFR_COLS, SPECTRUM_COLS, dataset # noqa: E402 +from ml.train import evaluate, make_model, report_md # noqa: E402 + +RAW = Path("data/raw") +OUT = Path(__file__).resolve().parent +MODELS = Path("ml/models") + +SUBSETS = { + "all features": FEATURE_COLS, + "BLE only (no spectrum)": BLE_COLS + MFR_COLS, + "spectrum only": SPECTRUM_COLS, +} + +# Brand tokens (docs/brand/tokens.json, light theme). +INK, INK_MUTED, LINE, PAPER = "#0E1726", "#4B5871", "#D3DAE4", "#FFFFFF" +BAND_COLORS = {"near": "#1F6FEB", "mid": "#D97706", "far": "#6B7280"} + + +def load() -> pd.DataFrame: + df = dataset(RAW) + info = {} + for s in df["session"].unique(): + meta = json.loads((RAW / s / "session.json").read_text(encoding="utf-8")) + dev = next(iter(meta["devices"].values())) + info[s] = (dev["model"], float(dev["distance_m"])) + df["device"] = df["session"].map(lambda s: info[s][0]) + df["dist"] = df["session"].map(lambda s: info[s][1]) + return df + + +def cv_predict(df: pd.DataFrame, target: str, cols: list[str], group: str) -> tuple[np.ndarray, np.ndarray]: + """Leave one group out: each session (or device) is predicted by a model that never saw it.""" + X, y, g = df[cols].to_numpy(dtype=float), df[target].to_numpy(), df[group] + pred = np.empty(len(y), dtype=object) + for tr, te in LeaveOneGroupOut().split(X, y, g): + assert not set(g.iloc[tr]) & set(g.iloc[te]) + pred[te] = make_model().fit(X[tr], y[tr]).predict(X[te]) + return y, pred + + +def score(y, pred) -> str: + return f"accuracy {accuracy_score(y, pred):6.1%} balanced {balanced_accuracy_score(y, pred):6.1%}" + + +def checks(df: pd.DataFrame) -> str: + out = [] + w = out.append + + w("Windows per device and distance (5 s windows, 1 s step)") + w(df.groupby(["device", "dist"]).size().unstack(fill_value=0).to_string()) + w("") + + w("== Band, three classes ==") + for name, cols in SUBSETS.items(): + for group, label in (("session", "leave one session out"), ("device", "leave one device out")): + y, p = cv_predict(df, "band", cols, group) + w(f"{name:24s} {label:22s} {score(y, p)}") + w("") + + core = df[df["dist"].isin([0.5, 1.5, 2.5, 3.0, 3.5])] + w("== Band without the 1.0 m and 2.0 m sessions (they sit on band edges) ==") + for name in ("all features", "BLE only (no spectrum)"): + y, p = cv_predict(core, "band", SUBSETS[name], "session") + w(f"{name}: {score(y, p)}") + w(pd.crosstab(pd.Series(y, name="true"), pd.Series(p, name="predicted")).to_string()) + w("") + + mf = df[df["band"].isin(["mid", "far"])] + w("== Mid vs far only (chance is 50% balanced) ==") + for name in ("all features", "BLE only (no spectrum)"): + for group, label in (("session", "leave one session out"), ("device", "leave one device out")): + y, p = cv_predict(mf, "band", SUBSETS[name], group) + w(f"{name:24s} {label:22s} {score(y, p)}") + w("") + y, p = cv_predict(mf, "band", SUBSETS["BLE only (no spectrum)"], "session") + w("Mid vs far, BLE only, leave one session out: windows predicted per session") + w(pd.crosstab([mf["device"], mf["dist"]], pd.Series(p, index=mf.index, name="predicted")).to_string()) + w("") + w("Mid vs far, BLE only, one model per device (leave one session out)") + for dev, g in mf.groupby("device"): + if g["band"].nunique() < 2: + w(f"{dev}: only one band recorded, skipped") + continue + y, p = cv_predict(g, "band", SUBSETS["BLE only (no spectrum)"], "session") + w(f"{dev}: {score(y, p)} ({g['session'].nunique()} sessions)") + w("") + + w("== Spectrum by session, in recording order ==") + w("The nRF24 sees the whole room. If these move with the clock and not with distance,") + w("the spectrum features describe the room's Wi-Fi traffic, not the test device.") + first = df.groupby("session")["t_start"].min().sort_values() + s = df.groupby("session")[["spec_active", "spec_mean_frac", "rssi_median"]].median().loc[first.index] + s.insert(0, "minute", ((first - first.iloc[0]) / 60000).round().astype(int).to_numpy()) + s.insert(1, "device", [df.loc[df["session"] == x, "device"].iat[0] for x in s.index]) + s.insert(2, "dist", [df.loc[df["session"] == x, "dist"].iat[0] for x in s.index]) + w(s.reset_index(drop=True).to_string(float_format=lambda v: f"{v:.3f}")) + w("") + + w("== Type (phone vs earpiece) ==") + type_subsets = { + "all features": FEATURE_COLS, + "no manufacturer columns": BLE_COLS + SPECTRUM_COLS, + "BLE timing and RSSI only": BLE_COLS, + } + for name, cols in type_subsets.items(): + y, p = cv_predict(df, "type", cols, "session") + w(f"{name:26s} leave one session out {score(y, p)}") + w("Leave one device out is not possible for type: there is only one earpiece.") + return "\n".join(out) + "\n" + + +def plot(df: pd.DataFrame) -> None: + devices = sorted(df["device"].unique()) + fig, axes = plt.subplots(1, len(devices), figsize=(3.2 * len(devices), 3.6), sharey=True) + fig.patch.set_facecolor(PAPER) + for ax, dev in zip(axes, devices): + g = df[df["device"] == dev] + dists = sorted(g["dist"].unique()) + data = [g.loc[g["dist"] == d, "rssi_median"] for d in dists] + parts = ax.boxplot(data, positions=range(len(dists)), widths=0.6, patch_artist=True, showfliers=False) + for box, d in zip(parts["boxes"], dists): + band = g.loc[g["dist"] == d, "band"].iat[0] + box.set(facecolor=BAND_COLORS[band], edgecolor=INK, alpha=0.85) + for med in parts["medians"]: + med.set(color=INK) + ax.set_xticks(range(len(dists)), [f"{d:g}" for d in dists]) + ax.set_title(dev, color=INK, fontsize=10) + ax.set_xlabel("distance (m)", color=INK_MUTED) + ax.grid(axis="y", color=LINE) + ax.set_axisbelow(True) + axes[0].set_ylabel("median RSSI per 5 s window (dBm)", color=INK_MUTED) + handles = [plt.Rectangle((0, 0), 1, 1, color=c) for c in BAND_COLORS.values()] + fig.legend(handles, BAND_COLORS, loc="upper right", frameon=False, ncol=3) + fig.suptitle("Window RSSI by distance: mid and far overlap", x=0.01, ha="left", color=INK) + fig.tight_layout(rect=(0, 0, 1, 0.92)) + fig.savefig(OUT / "rssi_by_distance.png", dpi=150) + + +def main() -> None: + df = load() + results = [evaluate(df, t) for t in ("type", "band")] + (OUT / "train_output.md").write_text(report_md(results, RAW), encoding="utf-8") + MODELS.mkdir(parents=True, exist_ok=True) + for r in results: + pd.DataFrame(r["confusion"], index=r["labels"], columns=r["labels"]).to_csv(OUT / f"confusion_{r['target']}.csv") + joblib.dump( + {"model": r["model"], "features": FEATURE_COLS, "classes": r["labels"]}, + MODELS / f"{r['target']}.joblib", + ) + print(f"{r['target']}: unseen sessions {r['test_acc']:.1%}, training data {r['train_acc']:.1%}") + (OUT / "checks.txt").write_text(checks(df), encoding="utf-8") + plot(df) + print(f"wrote {OUT}") + + +if __name__ == "__main__": + main() diff --git a/docs/results/2026-11-22-first-model/report.md b/docs/results/2026-11-22-first-model/report.md new file mode 100644 index 0000000..e6e9724 --- /dev/null +++ b/docs/results/2026-11-22-first-model/report.md @@ -0,0 +1,144 @@ +# First model: device type and distance band + +Date: 2026-11-22. Data: the 24 labelled calibration sessions from the same day (see [the calibration report](../2026-11-22-calibration/report.md)). Bands as in `docs/data-protocol.md`: near under 1 m, mid 1 to 2 m, far 2 to 3.5 m. Model: the random forest in `ml/train.py`, all 24 features in `ml/features.py`, 5 s windows with a 1 s step. + +Files in this folder: + +- `make_checks.py`: makes everything below from `data/raw/` (run from the repo root). It also saves both models to `ml/models/`, which is gitignored. +- `train_output.md`: the standard `ml.train` report. +- `confusion_type.csv`, `confusion_band.csv`: the two confusion matrices. +- `checks.txt`: the extra checks quoted below. +- `rssi_by_distance.png`: window RSSI by distance for each device. + +## Summary + +| | Accuracy on unseen sessions | Target | Result | +| --- | --- | --- | --- | +| Device type (DR2) | 100.0% | 85% | Passes on paper, but proves little: one earpiece, no smartwatch, no `allowed` device | +| Distance band (DR3) | 59.7% | 80% | Fails | + +**Mid vs far is not separable with this data.** From the device's own Bluetooth signal, a model that has never seen the session scores 48.9% on mid vs far, which is a coin toss. The model only gets above chance by using the nRF spectrum features, and those follow the room's Wi-Fi traffic over the day, not the distance. Near against the rest works well: 94% of near windows are found when the 1 m edge sessions are left out. + +## How it was tested + +Whole sessions are held out, never single windows: `ml.train` splits the 24 sessions into 5 groups and tests each group with a model trained on the other four. Every window is predicted by a model that never saw its session. The extra checks in `checks.txt` also use leave one session out (24 folds) and leave one device out (4 folds: test on a device the model never saw). + +| Device | Distances | Windows | Type label | +| --- | --- | --- | --- | +| Phone B (fab lab iPhone) | 0.5 to 3.5 m, 7 sessions | 385 | phone | +| Phone B class (iPhone) | 0.5, 1, 1.5 m | 164 | phone | +| Phone C class (Android, nRF Connect) | 0.5 to 3.5 m, 7 sessions | 327 | phone | +| Earpiece B class (Oraimo, case open) | 0.5 to 3.5 m, 7 sessions | 380 | earpiece | + +1256 windows in total. Phone C at 3 m has only 7 windows (8 readings in the session). + +`0x0942` (Oraimo) was already in `KNOWN_MFR`: it was added with the calibration report (#18), so no code change was needed for it. + +## Device type + +Accuracy on unseen sessions **100.0%**, on training data 100.0%. Every banned device was flagged as banned. + +| true \ predicted | phone | earpiece | +| --- | --- | --- | +| phone | 876 | 0 | +| earpiece | 0 | 380 | + +Top features (random forest importance): + +| Feature | Importance | +| --- | --- | +| `mfr_oraimo` | 0.273 | +| `n_adv` | 0.195 | +| `adv_interval_ms` | 0.183 | +| `mfr_apple` | 0.076 | +| `mfr_none` | 0.047 | +| `spec_active` | 0.043 | + +What the 100% means: the only earpiece is the only Oraimo device, so the model has learned "Oraimo means earpiece". With the manufacturer columns removed it still scores 97.9%, because the earpiece advertises about 1.5 times a second and the phones 2.7 to 6.4 times. Both are facts about these four devices, not about earpieces in general. The model has never been tested on an earpiece it did not train on, and cannot be until a second earpiece is recorded. Smartwatch and `allowed` have no data at all (the Huawei watch was not heard while connected), so the type model is really a two-class phone vs Oraimo model for now. Do not quote 100% as a DR2 result. + +## Distance band + +Accuracy on unseen sessions **59.7%**, on training data 96.9%. The gap means the model fits each session it trained on but does not carry that over to new ones. + +| true \ predicted | near | mid | far | +| --- | --- | --- | --- | +| near | 98 | 121 | 1 | +| mid | 85 | 317 | 196 | +| far | 1 | 102 | 335 | + +Top features: + +| Feature | Importance | +| --- | --- | +| `rssi_median` | 0.173 | +| `rssi_mean` | 0.162 | +| `rssi_max` | 0.156 | +| `spec_active` | 0.117 | +| `rssi_min` | 0.096 | +| `spec_mean_frac` | 0.077 | +| `spec_adv_frac` | 0.044 | +| `adv_interval_ms` | 0.042 | + +RSSI leads, as expected. The two spectrum features in the top six are the problem (next section). + +### The spectrum features leak the clock + +The nRF24 sees the whole room, and a phone or earpiece advertising at 1.5 m or more is far below the RPD threshold (about -64 dBm). So the spectrum features should say nothing about the test device's distance. They change with the time of day instead: + +| Sessions (in recording order) | Minutes after the first | Channels active (median) | Mean hit fraction | +| --- | --- | --- | --- | +| Phone B, all distances | 0 to 13 | 68 to 77 | 0.05 to 0.07 | +| Phone B class and phone C class | 95 to 130 | 31 to 36 | 0.016 to 0.022 | +| Earpiece 0.5 to 2 m | 194 to 199 | 28 to 38 | 0.017 to 0.021 | +| Earpiece 2.5 to 3.5 m | 202 to 204 | 45 to 52 | 0.022 to 0.061 | + +The Wi-Fi in the room got busier just as the earpiece moved to the far distances, so "busy spectrum" lines up with "far" for the earpiece by chance. Each device's distances were recorded in order (0.5 m first, 3.5 m last), which makes any drift look like distance. With the spectrum features removed: + +| Features | Leave one session out | Leave one device out | +| --- | --- | --- | +| All | 62.9% | 62.6% | +| BLE only | 44.3% | 53.3% | +| Spectrum only | 42.8% | 45.2% | + +The honest band number with this data is the BLE-only one, about 44 to 53%. + +### Near + +Near is the band that works. The low near recall in the matrix above (98 of 220) comes from the 1 m sessions: 1 m is the edge between near and mid, and phone B reads -64 dBm at 0.5 m and -67 dBm at 1 m. Leaving out the sessions that sit exactly on an edge (1 m and 2 m), the BLE-only model finds 208 of 220 near windows (94.5%) and calls only 2 mid or far windows near. + +### Mid vs far + +| Features | Leave one session out (balanced) | Leave one device out (balanced) | +| --- | --- | --- | +| All | 70.1% | 55.9% | +| BLE only | 48.9% | 53.7% | + +Chance is 50%. Without the spectrum leak, mid vs far is at chance, and even one model per device does no better (earpiece 60.0%, phone B 57.6%, phone C 48.7%, each from 6 sessions). With 1 m and 2 m left out, the BLE-only model got 9 of 217 mid windows right (the 1.5 m sessions) and called the rest far. + +The graph shows why. Past 1.5 m the window RSSI stops falling: phone B's boxes at 1.5, 2, 2.5, 3 and 3.5 m overlap almost completely around -78 dBm, and the earpiece at 1.5 m (-85 dBm) is weaker than at 3 m (-77 dBm). In a room with a bench, walls and people, reflections decide the RSSI past about 1.5 m, not the distance. + +![Window RSSI by distance](rssi_by_distance.png) + +## Plain answer: is mid vs far separable? + +No, not with this data. On the device's own Bluetooth signal the model does no better than a coin toss, on every split tried. The 60 to 70% figures above only exist because the room's Wi-Fi got busier while the far sessions were being recorded. + +Some of this is the data, not the physics: + +- One 60 s session per device per distance, all in one room, one position (desk), on one afternoon. +- Distances recorded in order, so drift in the room lines up with distance. +- Two of the six mid points (1 m and 2 m) sit exactly on a band edge. + +What would show whether it can be separated at all: + +1. Record mid at 1.5 m and far at 3 m only (the protocol's "record at" points), several sessions each, in shuffled order, at two or three spots in the room. +2. Repeat on another day or in another room, and hold that day out completely. +3. Check RSSI against distance with the unit raised off the bench, since the flat region may come from the bench and nearby walls. + +If mid and far still overlap after that, the options are two bands (near, not near) with one unit, or Phase 2 multi-node localization. Both change the AI questions, so they need a decision first. + +## Before the next training run + +- Remove the spectrum features from the band model, or record so they cannot line up with distance (shuffled order, baselines between sessions). They are meant for spotting audio streaming, and none of these sessions streamed. +- Record a second earpiece, a smartwatch that can be heard, and an `allowed` device, so the type score means something. +- Repeat phone C at 3 m (8 readings) and phone B class past 1.5 m. diff --git a/docs/results/2026-11-22-first-model/rssi_by_distance.png b/docs/results/2026-11-22-first-model/rssi_by_distance.png new file mode 100644 index 0000000..a995fd2 Binary files /dev/null and b/docs/results/2026-11-22-first-model/rssi_by_distance.png differ diff --git a/docs/results/2026-11-22-first-model/train_output.md b/docs/results/2026-11-22-first-model/train_output.md new file mode 100644 index 0000000..f273bf4 --- /dev/null +++ b/docs/results/2026-11-22-first-model/train_output.md @@ -0,0 +1,84 @@ +# Training run 2026-11-22 + +Data: `data\raw` + +## type + +- Rows: 1256 windows from 24 sessions +- Accuracy on unseen sessions: **100.0%** (DR2 classification accuracy, target 85%: PASS) +- Accuracy on training data: 100.0% + A big gap between these two means the model memorized the training sessions. +- Banned devices flagged as banned: 100.0% + +Confusion matrix (rows: true, columns: predicted) + +``` + phone earpiece +phone 876 0 +earpiece 0 380 +``` + +``` + precision recall f1-score support + + phone 1.00 1.00 1.00 876 + earpiece 1.00 1.00 1.00 380 + + accuracy 1.00 1256 + macro avg 1.00 1.00 1.00 1256 +weighted avg 1.00 1.00 1.00 1256 +``` + +Top features + +- mfr_oraimo: 0.273 +- n_adv: 0.195 +- adv_interval_ms: 0.183 +- mfr_apple: 0.076 +- mfr_none: 0.047 +- spec_active: 0.043 +- spec_adv_frac: 0.037 +- spec_longest_run: 0.023 +- spec_sweeps: 0.023 +- spec_scattered: 0.022 + +## band + +- Rows: 1256 windows from 24 sessions +- Accuracy on unseen sessions: **59.7%** (DR3 distance band accuracy, target 80%: FAIL) +- Accuracy on training data: 96.9% + A big gap between these two means the model memorized the training sessions. + +Confusion matrix (rows: true, columns: predicted) + +``` + near mid far +near 98 121 1 +mid 85 317 196 +far 1 102 335 +``` + +``` + precision recall f1-score support + + near 0.53 0.45 0.49 220 + mid 0.59 0.53 0.56 598 + far 0.63 0.76 0.69 438 + + accuracy 0.60 1256 + macro avg 0.58 0.58 0.58 1256 +weighted avg 0.59 0.60 0.59 1256 +``` + +Top features + +- rssi_median: 0.173 +- rssi_mean: 0.162 +- rssi_max: 0.156 +- spec_active: 0.117 +- rssi_min: 0.096 +- spec_mean_frac: 0.077 +- spec_adv_frac: 0.044 +- adv_interval_ms: 0.042 +- n_adv: 0.027 +- spec_longest_run: 0.027