def METHOD_NAME(self, X: DataFrame):
    X = self.pd_to_np(X)
    mask = np.zeros(shape=X.shape, dtype=bool)
    for col in range(self.num_cols):
        mask[:, col] = np.isin(X[:, col], self.cats[col], invert=True)
    X[mask] = self.infrequent_val
    return X