def adj_r2(r2: float, sample_size: int, n_features: int) -> float:
    """
    >>> round(adj_r2(0.8, 100, 5), 3)
    0.789
    >>> round(adj_r2(0.8, 20, 5), 3)
    0.729
    """
    return 1 - ((sample_size - 1) / (sample_size - n_features - 1)) * (1 - r2)