Table Tennis API Tutorials

How Head-to-Head Data Improves Table Tennis Predictions

Learn how previous meetings, set history, ranking differences, recent form and Elo-style ratings can be transformed into useful table tennis prediction features while avoiding sample-size errors and data leakage.

Table Tennis Prediction Data Guide

How Head-to-Head Data Improves Table Tennis Predictions

Learn how previous meetings, set history, rankings, recent form and matchup context can strengthen table tennis prediction models without treating head-to-head data as a guaranteed forecasting shortcut.

Head-to-head data is one of the most intuitive signals in table tennis: if two players have met before, those matches contain direct evidence about how they performed against each other.

But H2H is useful only when it is interpreted correctly. A 4–1 matchup record can mean very different things depending on when those matches happened, how close the sets were, what each player’s ranking was at the time and whether recent form has changed.

This guide shows how to turn raw previous meetings into better prediction features while avoiding tiny sample sizes, stale history and data leakage.

Important: H2H can improve model context, but it does not guarantee an outcome. Prediction systems should combine matchup history with rankings, form, statistics and other validated features.

1. What Does Head-to-Head Data Contain?

Head-to-head data describes previous direct meetings between two players. A useful H2H endpoint should expose much more than a simple win-loss total.

Previous meetings

Every supported match played between the two players.

Win/loss record

How many direct meetings each player won.

Set history

The set-level score from each previous match.

Match dates

Needed to distinguish recent meetings from old ones.

Tournament context

Competition and round information where available.

Historical rankings

The player-strength context that existed before each meeting.

Illustrative H2H summary
{
  "meetings": 8,
  "player_a_wins": 5,
  "player_b_wins": 3,
  "player_a_sets_won": 22,
  "player_b_sets_won": 17
}

2. Why Can H2H Improve Predictions?

Rankings and general win rates describe how players perform against the field. H2H adds a different question: how do these two players perform against each other?

Some matchups can behave differently from broad player-strength indicators. Direct history may reveal that one player consistently performs better against a particular opponent, even when their overall records are closer.

H2H is most useful as an additional matchup feature, not as a replacement for broader player-strength data.

3. Useful H2H Features for a Prediction Model

FeatureWhat it captures
h2h_win_rateDirect win percentage against the opponent.
h2h_set_win_rateShare of directly contested sets won.
recent_h2h_win_rateDirect performance over the latest selected meetings.
h2h_meeting_countSample-size indicator for how much direct evidence exists.
days_since_last_h2hHow fresh the most recent direct meeting is.
avg_h2h_set_marginWhether direct wins tended to be comfortable or close.
h2h_rank_adjustedDirect performance interpreted alongside historical rankings.

These features turn a raw list of matches into structured inputs that a model can evaluate consistently.

4. Start With a Simple H2H Win Rate

Formula
h2h_win_rate =
player_wins / total_meetings

Player A wins: 5

Total meetings: 8

H2H win rate: 0.625

That number is useful, but it should not be interpreted without sample size and recency.

5. Sample Size Changes How Much H2H Should Matter

H2H recordInterpretation
1–0Very little direct evidence.
2–0Still a small sample.
5–0Stronger direct pattern, subject to recency and context.
12–0Potentially meaningful pattern, but historical relevance still matters.
Do not let a 1–0 record overpower much stronger ranking, statistical and recent-form evidence.

6. Set History Can Reveal More Than Match Wins

Two players can have a 3–3 match record while one player has consistently won their matches comfortably and lost only narrow contests.

Same H2H record, different story

Match record: 3–3

Player A sets won: 15

Player B sets won: 10

Set win rate
h2h_set_win_rate =
player_sets_won /
(player_sets_won + opponent_sets_won)

7. Look at the Margin of Previous Sets

A model can also describe whether previous sets were consistently close or one-sided.

Illustrative set-margin feature
set_margin =
player_points - opponent_points

average_h2h_set_margin =
mean(set_margin across supported H2H sets)

Point-level historical depth may not exist for every competition or old match, so use this only where the dataset supports it.

8. Recent H2H Usually Deserves More Attention Than Old H2H

A meeting from several years ago may describe two very different versions of the players compared with a match from last month.

Conceptual recency weighting
weight =
exp(-decay_rate × days_since_match)

weighted_h2h =
sum(match_result × weight) /
sum(weight)
The decay rate is model-specific and should be tuned and validated, not copied as a universal constant.

9. Keep Career H2H and Recent H2H Separate

Career H2H: Player A leads 8–5

Last 5 meetings: Player B leads 3–2

That tells a more nuanced story than either number alone.

10. Combine H2H With Player Rankings

Ranking difference describes general player strength while H2H describes the direct matchup.

FeaturePlayer APlayer B
Current ranking815
Career H2H wins43
Last 3 H2H12
Recent form4–15–0

In this example, current ranking favours Player A while recent H2H and form lean toward Player B. A model can evaluate all three instead of relying on one headline metric.

11. Use Historical Rankings for Historical H2H

If you are analysing an old H2H match, current ranking is not the ranking that existed when the match was played.

Correct historical join
historical_match_date
        ↓
latest ranking release
BEFORE historical_match_date
        ↓
ranking difference at match time
Avoid data leakage: never enrich an old training match with ranking information published after that match occurred.

12. Combine H2H With Recent Form

Direct matchup history can become stale. Recent form helps describe the player’s current competitive state.

Recent win rate

Wins over the latest selected match window.

Set win rate

Recent ability to convert individual sets.

Win streak

Current sequence of consecutive wins.

Opponent strength

Context around who those recent results came against.

13. Add an Elo-Style Rating Difference

Elo-style systems provide a continuously updated player-strength signal that can complement official rankings and H2H.

Conceptual rating difference
elo_difference =
player_a_elo - player_b_elo
Elo is a modelling method, not an official ITTF ranking. Keep the labels separate in your product.

14. H2H Is Evidence, Not Causality

A player may lead the direct series for reasons that no longer apply. Their opponent may have improved, the ranking gap may have reversed or the sample may come from a different stage of both players’ careers.

“Player A leads the H2H” is a data statement. “Player A will win because they lead the H2H” is a prediction claim that still needs model support.

15. Retrieve H2H Data Through an API

Illustrative endpoint
GET /v1/table-tennis/head-to-head
    ?player_a_id=player_tt_101
    &player_b_id=player_tt_204
    &limit=20
Illustrative response
{
  "summary": {
    "meetings": 8,
    "player_a_wins": 5,
    "player_b_wins": 3,
    "player_a_sets_won": 22,
    "player_b_sets_won": 17
  },
  "matches": [
    {
      "match_id": "match_tt_40021",
      "played_at": "2026-05-14T11:00:00Z",
      "winner_id": "player_tt_101",
      "sets": {
        "player_a": 4,
        "player_b": 2
      }
    }
  ]
}

16. Build H2H Features in JavaScript

JavaScript
function buildH2HFeatures(h2h, playerAId) {
  const meetings = h2h.matches.length;

  const wins = h2h.matches.filter(
    match => match.winner_id === playerAId
  ).length;

  const winRate = meetings
    ? wins / meetings
    : null;

  return {
    h2h_meetings: meetings,
    h2h_wins: wins,
    h2h_win_rate: winRate
  };
}

17. Add Recency-Aware H2H Features

JavaScript
function recentH2H(matches, playerId, limit = 5) {
  const recent = [...matches]
    .sort(
      (a, b) =>
        new Date(b.played_at) - new Date(a.played_at)
    )
    .slice(0, limit);

  const wins = recent.filter(
    match => match.winner_id === playerId
  ).length;

  return {
    recent_h2h_matches: recent.length,
    recent_h2h_wins: wins,
    recent_h2h_win_rate:
      recent.length ? wins / recent.length : null
  };
}

18. Create One Model-Ready Feature Row

After joining H2H, ranking and form data, your model can consume a compact feature vector.

Illustrative feature row
{
  "ranking_difference": -7,
  "elo_difference": 42,
  "h2h_meetings": 8,
  "h2h_win_rate": 0.625,
  "recent_h2h_win_rate": 0.60,
  "h2h_set_win_rate": 0.564,
  "recent_form_win_rate": 0.80,
  "days_since_last_h2h": 51
}

The values above are illustrative. Real features must be calculated only from historical data available before the target match.

19. Avoid H2H Leakage in Model Training

When creating a training row for a historical match, include only H2H meetings that happened before that match.

Correct filtering logic
training_match_date = 2026-06-10

allowed_h2h =
all_direct_meetings
WHERE played_at < training_match_date
If the training row includes a later H2H meeting, the model is learning from the future.

20. Treat First-Time Matchups Differently

Some players have never met. That is not an error condition.

No prior meetings
{
  "h2h_meetings": 0,
  "h2h_win_rate": null,
  "recent_h2h_win_rate": null,
  "h2h_set_win_rate": null
}

The model should then rely naturally on rankings, Elo, recent form, tournament performance and other available features.

21. Do Not Invent Missing H2H History

Historical coverage may vary by competition and date. A provider returning two previous meetings does not necessarily prove that the players met only twice in their careers.

Interpret H2H as “meetings available in the supported dataset” unless historical coverage is known to be complete.

22. Validate Whether H2H Actually Improves the Model

Train a baseline modelUse rankings, form and other non-H2H features.
Add H2H featuresInclude meeting count, win rate, set rate and recency.
Evaluate out of sampleUse time-aware validation rather than random future leakage.
Compare calibration and accuracyKeep H2H only if it improves real predictive performance.

23. H2H Is Useful Beyond Prediction Models

Match previews

Show previous meetings before an upcoming match.

Broadcast graphics

Add direct matchup context during coverage.

Player pages

Explore performance against specific opponents.

Analytics dashboards

Compare direct performance with broader ranking and form signals.

24. Production Checklist

  • Use stable player IDs for both sides of the matchup
  • Store direct meeting dates
  • Preserve set-level scores where available
  • Store tournament context where available
  • Keep a direct meeting count as a sample-size feature
  • Separate career H2H from recent H2H
  • Use historical rankings from before each old match
  • Exclude future H2H meetings from training rows
  • Return null instead of fabricating missing H2H data
  • Validate that H2H improves out-of-sample performance
  • Keep H2H separate from official rankings and Elo ratings
  • Confirm historical depth before claiming career-complete H2H

Common H2H Prediction Mistakes

Overweighting 1–0

One meeting is a very small sample.

Ignoring recency

Very old meetings may describe different player strength.

Ignoring set history

A match-only record can hide how close the meetings were.

Using current rankings historically

This can introduce future information into training data.

Assuming missing means zero

No returned meeting may reflect incomplete historical coverage.

Treating H2H as a guarantee

Direct history is evidence, not certainty.

Frequently Asked Questions

Does H2H data improve table tennis predictions?

It can add useful matchup context, but the improvement should be validated out of sample rather than assumed.

How many H2H matches are enough?

There is no universal threshold. More meetings generally provide more evidence, but recency and context still matter.

Should recent H2H count more than old H2H?

Often yes, because player strength changes over time. The weighting method should be validated historically.

Is match win rate enough?

Set history, sample size and recency can add useful detail beyond a simple win-loss record.

Should H2H replace rankings?

No. H2H and rankings describe different things and are generally more useful together.

Can I use H2H in an Elo model?

Yes, as a separate feature or adjustment, while keeping Elo and H2H conceptually distinct.

What if two players have never met?

Use null or no-history indicators and let the model rely on other player-strength features.

Build Better Matchup Features With H2H Data

Combine previous meetings with rankings, recent form, statistics and historical context to create richer table tennis prediction features.

Head-to-Head API Statistics API Rankings API

Build Cricket Products With Reliable API Data

Access live scores, fixtures, ball-by-ball updates, statistics, odds, predictions and historical cricket data through one developer-friendly API.

Get API Access
Written By

James

Chat on WhatsApp