  The mass ratio $q$ of a contact binary star evolves due to mass transfer,
magnetic braking, and thermal relaxation oscillations to small values until it
crosses a critical threshold $q_\text{min}$. When that happens, the binary
undergoes the tidal Darwin instability, leading to a rapid coalescence of the
components and observable brightening of the system. So far, the distribution
of $q$ has not been measured on a sufficiently large population of contact
binary stars, because the determination of $q$ for a single contact binary
usually requires spectroscopy. But as was shown previously, it is possible to
infer the mass-ratio distribution of the entire population of contact binaries
from the observed distribution of their light curve amplitudes. Employing
Bayesian inference, we obtain a sample of contact binary candidates from the
Kepler Eclipsing Binary Catalog combined with data from Gaia and estimates of
effective temperatures. We assign to each candidate a probability of being a
contact binary of either late or early type. Overall, our sample includes about
300 late-type and 200 early-type contact binary candidates. We model the
amplitude distribution assuming that mass ratios are described by a power law
with an exponent $b$ and a cut off at $q_\text{min}$. We find
$q_\text{min}=0.087^{+0.024}_{-0.015}$ for late-type contact binaries with
periods longer than 0.3 days. For late-type binaries with shorter periods, we
find $q_\text{min}=0.246^{+0.029}_{-0.046}$, but the sample is small. For early
type contact binary stars with periods shorter than 1 day, we obtain
$q_\text{min}=0.030^{+0.018}_{-0.022}$. These results indicate a dependence of
$q_\text{min}$ on the structure of the components and are broadly compatible
with previous theoretical predictions. Our method can be easily extended to
large samples of contact binaries from TESS and other space-based surveys.
