def _fit_with_samples(self, X, y, time_limit, start_samples=10000, max_samples=None, sample_growth_factor=2, sample_time_growth_factor=8):
    '\n        Fit model with samples of the data repeatedly, gradually increasing the amount of data until time_limit is reached or all data is used.\n\n        X and y must already be preprocessed.\n\n        Parameters\n        ----------\n        X : np.ndarray\n            The training data features (preprocessed).\n        y : Series\n            The training data ground truth labels.\n        time_limit : float, default = None\n            Time limit in seconds to adhere to when fitting model.\n        start_samples : int, default = 10000\n            Number of samples to start with. This will be multiplied by sample_growth_factor after each model fit to determine the next number of samples.\n            For example, if start_samples=10000, sample_growth_factor=2, then the number of samples per model fit would be [10000, 20000, 40000, 80000, ...]\n        max_samples : int, default = None\n            The maximum number of samples to use.\n            If None or greater than the number of rows in X, then it is set equal to the number of rows in X.\n        sample_growth_factor : float, default = 2\n            The rate of growth in sample size between each model fit. If 2, then the sample size doubles after each fit.\n        sample_time_growth_factor : float, default = 8\n            The multiplier to the expected fit time of the next model. If `sample_time_growth_factor=8` and a model took 10 seconds to train, the next model fit will be expected to take 80 seconds.\n            If an expected time is greater than the remaining time in `time_limit`, the model will not be trained and the method will return early.\n        '
    time_start = time.time()
    num_rows_samples = []
    if (max_samples is None):
        num_rows_max = len(X)
    else:
        num_rows_max = min(len(X), max_samples)
    num_rows_cur = start_samples
    while True:
        num_rows_cur = min(num_rows_cur, num_rows_max)
        num_rows_samples.append(num_rows_cur)
        if (num_rows_cur == num_rows_max):
            break
        num_rows_cur *= sample_growth_factor
        num_rows_cur = math.ceil(num_rows_cur)
        if ((num_rows_cur * 1.5) >= num_rows_max):
            num_rows_cur = num_rows_max

    def sample_func(chunk, frac):
        n = max(math.ceil((len(chunk) * frac)), 1)
        return chunk.sample(n=n, replace=False, random_state=0)
    if (self.problem_type != REGRESSION):
        y_df = y.to_frame(name='label').reset_index(drop=True)
    else:
        y_df = None
    time_start_sample_loop = time.time()
    time_limit_left = (time_limit - (time_start_sample_loop - time_start))
    model_type = self._get_model_type()
    idx = None
    for (i, samples) in enumerate(num_rows_samples):
        if (samples != num_rows_max):
            if (self.problem_type == REGRESSION):
                idx = np.random.choice(num_rows_max, size=samples, replace=False)
            else:
                idx = y_df.groupby('label', group_keys=False).apply(sample_func, frac=(samples / num_rows_max)).index
            X_samp = X[idx, :]
            y_samp = y.iloc[idx]
        else:
            X_samp = X
            y_samp = y
            idx = None
        self.model = model_type(**self._get_model_params()).fit(X_samp, y_samp)
        time_limit_left_prior = time_limit_left
        time_fit_end_sample = time.time()
        time_limit_left = (time_limit - (time_fit_end_sample - time_start))
        time_fit_sample = (time_limit_left_prior - time_limit_left)
        time_required_for_next = (time_fit_sample * sample_time_growth_factor)
        logger.log(15, f'	{round(time_fit_sample, 2)}s 	= Train Time (Using {samples}/{num_rows_max} rows) ({round(time_limit_left, 2)}s remaining time)')
        if ((time_required_for_next > time_limit_left) and (i != (len(num_rows_samples) - 1))):
            logger.log(20, f'	Not enough time to train KNN model on all training rows. Fit {samples}/{num_rows_max} rows. (Training KNN model on {num_rows_samples[(i + 1)]} rows is expected to take {round(time_required_for_next, 2)}s)')
            break
    if (idx is not None):
        idx = set(idx)
        self._X_unused_index = [i for i in range(num_rows_max) if (i not in idx)]
    return self.model
Fit model with samples of the data repeatedly, gradually increasing the amount of data until time_limit is reached or all data is used.

X and y must already be preprocessed.

Parameters
----------
X : np.ndarray
    The training data features (preprocessed).
y : Series
    The training data ground truth labels.
time_limit : float, default = None
    Time limit in seconds to adhere to when fitting model.
start_samples : int, default = 10000
    Number of samples to start with. This will be multiplied by sample_growth_factor after each model fit to determine the next number of samples.
    For example, if start_samples=10000, sample_growth_factor=2, then the number of samples per model fit would be [10000, 20000, 40000, 80000, ...]
max_samples : int, default = None
    The maximum number of samples to use.
    If None or greater than the number of rows in X, then it is set equal to the number of rows in X.
sample_growth_factor : float, default = 2
    The rate of growth in sample size between each model fit. If 2, then the sample size doubles after each fit.
sample_time_growth_factor : float, default = 8
    The multiplier to the expected fit time of the next model. If `sample_time_growth_factor=8` and a model took 10 seconds to train, the next model fit will be expected to take 80 seconds.
    If an expected time is greater than the remaining time in `time_limit`, the model will not be trained and the method will return early.
def _fit_with_samples(self, X, y, time_limit, start_samples=10000, max_samples=None, sample_growth_factor=2, sample_time_growth_factor=8):
    '\n        Fit model with samples of the data repeatedly, gradually increasing the amount of data until time_limit is reached or all data is used.\n\n        X and y must already be preprocessed.\n\n        Parameters\n        ----------\n        X : np.ndarray\n            The training data features (preprocessed).\n        y : Series\n            The training data ground truth labels.\n        time_limit : float, default = None\n            Time limit in seconds to adhere to when fitting model.\n        start_samples : int, default = 10000\n            Number of samples to start with. This will be multiplied by sample_growth_factor after each model fit to determine the next number of samples.\n            For example, if start_samples=10000, sample_growth_factor=2, then the number of samples per model fit would be [10000, 20000, 40000, 80000, ...]\n        max_samples : int, default = None\n            The maximum number of samples to use.\n            If None or greater than the number of rows in X, then it is set equal to the number of rows in X.\n        sample_growth_factor : float, default = 2\n            The rate of growth in sample size between each model fit. If 2, then the sample size doubles after each fit.\n        sample_time_growth_factor : float, default = 8\n            The multiplier to the expected fit time of the next model. If `sample_time_growth_factor=8` and a model took 10 seconds to train, the next model fit will be expected to take 80 seconds.\n            If an expected time is greater than the remaining time in `time_limit`, the model will not be trained and the method will return early.\n        '
    time_start = time.time()
    num_rows_samples = []
    if (max_samples is None):
        num_rows_max = len(X)
    else:
        num_rows_max = min(len(X), max_samples)
    num_rows_cur = start_samples
    while True:
        num_rows_cur = min(num_rows_cur, num_rows_max)
        num_rows_samples.append(num_rows_cur)
        if (num_rows_cur == num_rows_max):
            break
        num_rows_cur *= sample_growth_factor
        num_rows_cur = math.ceil(num_rows_cur)
        if ((num_rows_cur * 1.5) >= num_rows_max):
            num_rows_cur = num_rows_max

    def sample_func(chunk, frac):
        n = max(math.ceil((len(chunk) * frac)), 1)
        return chunk.sample(n=n, replace=False, random_state=0)
    if (self.problem_type != REGRESSION):
        y_df = y.to_frame(name='label').reset_index(drop=True)
    else:
        y_df = None
    time_start_sample_loop = time.time()
    time_limit_left = (time_limit - (time_start_sample_loop - time_start))
    model_type = self._get_model_type()
    idx = None
    for (i, samples) in enumerate(num_rows_samples):
        if (samples != num_rows_max):
            if (self.problem_type == REGRESSION):
                idx = np.random.choice(num_rows_max, size=samples, replace=False)
            else:
                idx = y_df.groupby('label', group_keys=False).apply(sample_func, frac=(samples / num_rows_max)).index
            X_samp = X[idx, :]
            y_samp = y.iloc[idx]
        else:
            X_samp = X
            y_samp = y
            idx = None
        self.model = model_type(**self._get_model_params()).fit(X_samp, y_samp)
        time_limit_left_prior = time_limit_left
        time_fit_end_sample = time.time()
        time_limit_left = (time_limit - (time_fit_end_sample - time_start))
        time_fit_sample = (time_limit_left_prior - time_limit_left)
        time_required_for_next = (time_fit_sample * sample_time_growth_factor)
        logger.log(15, f'	{round(time_fit_sample, 2)}s 	= Train Time (Using {samples}/{num_rows_max} rows) ({round(time_limit_left, 2)}s remaining time)')
        if ((time_required_for_next > time_limit_left) and (i != (len(num_rows_samples) - 1))):
            logger.log(20, f'	Not enough time to train KNN model on all training rows. Fit {samples}/{num_rows_max} rows. (Training KNN model on {num_rows_samples[(i + 1)]} rows is expected to take {round(time_required_for_next, 2)}s)')
            break
    if (idx is not None):
        idx = set(idx)
        self._X_unused_index = [i for i in range(num_rows_max) if (i not in idx)]
    return self.model