Derek Li, Software & AI

Focus
Software engineering, applied machine learning
Stack
Python, PyTorch, scikit-learn, JavaScript
Degree
BSc Computer Science and AI, 2026

I build software, then test whether its machine learning holds up outside the lab.

Behind this card: the tuned Transformer from my final-year project

See the Wi-Fi experiment GitHub (opens in a new tab)
Schematic of a transmitter and five reference points one metre apart. A circle around the third point shows the reported mean error for the chosen experiment. 1 m2 m3 m4 m5 m Transmitter 30° −60° 1 m
Reference points 1 m apart, as in the Figshare setup. The circle is each experiment's reported mean error, drawn to scale.

Finding a room by its Wi-Fi

GPS is unreliable indoors. Wi-Fi Channel State Information records how a signal changes across antenna links and subcarriers, and those patterns can work as fingerprints of a place.

For my final-year project I trained classical and deep models to say which reference point in a room a recording came from.

0.040 m

Mean error of the tuned Transformer in the Qiang Meeting Room, trained and tested in matched conditions.

0.109 m

The tuned Transformer in the Qiang Lab, also in matched conditions. Still a few centimetres.

1.686 m

A Transformer trained with the transmitter at 30° and tested at −60°, on the Figshare Intel 5300 data.

That gap is the finding. Strong results in familiar conditions did not establish that the model would cope with a new orientation.

An Intel Mini PCIe Wi-Fi card lifted out of a laptop's expansion slot
An Intel Mini PCIe Wi-Fi card (WM3945ABG). The Figshare recordings came from its relative, the Intel 5300.
Reported results, from the submitted project report
ExperimentModelMean error
Qiang Meeting Room, matchedTuned Transformer0.040 m
Qiang Lab, matchedTuned Transformer0.109 m
Figshare, 30° train → −60° testTransformer1.686 m

What the numbers don't prove

This is reference-point classification followed by coordinate mapping, not centimetre-level positioning in a building the model has never seen. A correct classification scores exactly zero error. The three results come from different experiments and are not one accuracy claim.

Read the code and its limits (opens in a new tab)

From raw signal to metres

  1. First, read the coordinates

    Qiang's recordings are named like coordinate715.mat. The last two digits are y, the rest are x.

    def parse_coordinate_stem(stem: str) -> tuple[int, int]:
        m = re.search(r"coordinate\s*([0-9]+)$", stem, re.IGNORECASE)
        if not m:
            raise ValueError(f"Cannot parse coordinate from filename stem: {stem}")
        digits = m.group(1)
        if len(digits) < 3:
            raise ValueError(f"Coordinate code too short in filename stem: {stem}")
        x = int(digits[:-2])
        y = int(digits[-2:])
        return x, y
    convert_qiang_dataset.py
  2. Then read the angles

    Figshare's files carry the angle and distance, from loc_30deg_1m to loc_minus60deg_5m.

    distance = float(m.group(2))
    angle = 30.0 if angle_label == "30deg" else -60.0
    return angle_label, angle, distance
    
    def polar_xy(distance: float, angle_deg: float) -> Tuple[float, float]:
        rad = math.radians(angle_deg)
        return distance * math.cos(rad), distance * math.sin(rad)
    figshare_intel5300_prepare.py
  3. Clean and scale

    Missing or infinite amplitudes become zero. Scaling is fitted on the training data only.

    def normalise_per_feature_minmax(X: np.ndarray, eps: float = 1e-8) -> Tuple[np.ndarray, Dict[str, np.ndarray]]:
        X = sanitise_numeric_array(X)
        min_v = X.min(axis=0)
        max_v = X.max(axis=0)
        scale = np.maximum(max_v - min_v, eps)
        Xn = ((X - min_v) / scale).astype(np.float32)
        return sanitise_numeric_array(Xn), {"min": min_v.astype(np.float32), "scale": scale.astype(np.float32)}
    figshare_intel5300_prepare.py
  4. Cut into windows

    Packet streams are split into windows of ten packets, so each estimate sees a short burst.

    def chunk_array(X: np.ndarray, chunk_size: int) -> List[np.ndarray]:
        if chunk_size <= 1:
            return [X[i:i+1] for i in range(len(X))]
        return [X[i:i+chunk_size] for i in range(0, len(X), chunk_size) if len(X[i:i+chunk_size]) > 0]
    cnn_csi_windowed.py
  5. Try the classics

    k-nearest neighbours, an SVM and a random forest set the baseline to beat.

    def build_models(args) -> Dict[str, object]:
        return {
            "knn": Pipeline([
                ("scaler", StandardScaler()),
                ("model", KNeighborsClassifier(n_neighbors=args.knn_k, weights=args.knn_weights)),
            ]),
            "svm": Pipeline([
                ("scaler", StandardScaler()),
                ("model", SVC(
                    C=args.svm_c,
                    kernel=args.svm_kernel,
                    gamma=args.svm_gamma,
                    probability=True,
                    random_state=SEED,
                )),
            ]),
            "rf": RandomForestClassifier(
                n_estimators=args.rf_trees,
                max_depth=args.rf_max_depth,
                min_samples_leaf=args.rf_min_samples_leaf,
                n_jobs=args.jobs,
                random_state=SEED,
            ),
    classical_csi_baselines_windowed.py
  6. Try a CNN

    Convolutions read each window as a small image of packets by subcarriers. DeepFi-style and TCN models ran too.

    class CSICNNClassifier(nn.Module):
        def __init__(self, window_size: int, num_classes: int, dropout: float = 0.2, channels: int = 32):
            super().__init__()
            c1 = channels
            c2 = channels * 2
            c3 = channels * 4
            self.window_size = window_size
            self.features = nn.Sequential(
                nn.Conv2d(1, c1, kernel_size=(3, 5), padding=(1, 2)),
                nn.BatchNorm2d(c1),
                nn.ReLU(inplace=True),
                nn.Conv2d(c1, c1, kernel_size=(3, 3), padding=1),
                nn.BatchNorm2d(c1),
                nn.ReLU(inplace=True),
                nn.MaxPool2d(kernel_size=(1, 2)),
                nn.Conv2d(c1, c2, kernel_size=(3, 3), padding=1),
    cnn_csi_windowed.py
  7. Tune a Transformer

    Each packet becomes a token, with a learned class token that sums up the window.

    self.input_proj = nn.Sequential(
        nn.LayerNorm(input_dim),
        nn.Linear(input_dim, d_model),
        nn.GELU(),
        nn.Dropout(input_dropout),
    )
    self.cls_token = nn.Parameter(torch.zeros(1, 1, d_model))
    self.pos_embed = nn.Parameter(torch.zeros(1, window_size + 1, d_model))
    enc_layer = nn.TransformerEncoderLayer(
        d_model=d_model,
        nhead=nhead,
        dim_feedforward=dim_feedforward,
        dropout=dropout,
        batch_first=True,
        activation="gelu",
        norm_first=norm_first,
    )
    self.encoder = nn.TransformerEncoder(enc_layer, num_layers=num_layers)
    transformer_csi_tuned.py
  8. Measure in metres

    Each prediction maps to a reference point's coordinates. The error is the straight-line distance.

    def metrics_from_predictions(true_xy: np.ndarray, pred_xy: np.ndarray) -> Dict[str, float]:
        errors = np.linalg.norm(pred_xy - true_xy, axis=1).astype(np.float32)
        finite = errors[np.isfinite(errors)]
        if len(finite) == 0:
            raise ValueError("No finite localisation errors were produced.")
        return {
            "num_estimates": int(len(errors)),
            "num_finite_estimates": int(len(finite)),
            "mean_error_m": float(np.mean(finite)),
            "median_error_m": float(np.median(finite)),
            "p90_error_m": float(np.percentile(finite, 90)),
            "within_1m": float(np.mean(finite <= 1.0)),
    classical_csi_baselines_windowed.py

Agora

GPT and Claude answer the same question blind, critique each other, and code decides when they stop. A private app I built on Cloudflare, with a desktop client.

Read the case study

Text desk

12 words64 characters2 lines

Text desk

My first browser tool. It counts words and characters, tidies spacing and changes case. It runs entirely in your browser, so nothing you type is uploaded.

Hello, I'm Derek

I studied Computer Science and Artificial Intelligence at Queen Mary University of London, and graduated in 2026.

My final-year project asked a narrow question. If a model can tell where you are in a room from Wi-Fi, does it still work when the transmitter turns? Matched, it did very well. Turned, it did not.

That result shaped how I work. I like turning a question into an experiment, writing down what it does not prove, and building something other people can try.

Next, I'm applying for a master's degree. If you're working on something similar, I'd like to hear about it.

Derek Li

Software & applied AI