<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cost_sampling(X, y, cost_mat, method='RejectionSampling', oversampling_norm=0.1, max_wc=97.5):
 """Cost-proportionate sampling. Parameters X : array-like of shape = [n_samples, n_features] The input samples. y : array-like of shape = [n_samples] Ground truth (correct) labels. cost_mat : array-like of shape = [n_samples, 4] Cost matrix of the classification problem Where the columns represents the costs of: false positives, false negatives, true positives and true negatives, for each example. method : str, optional (default = RejectionSampling) Method to perform the cost-proportionate sampling, either 'RejectionSampling' or 'OverSampling'. oversampling_norm: float, optional (default = 0.1) normalize value of wc, the smaller the biggest the data. max_wc: float, optional (default = 97.5) outlier adjustment for the cost. References .. [1] B. Zadrozny, J. Langford, N. Naoki, "Cost-sensitive learning by cost-proportionate example weighting", in Proceedings of the Third IEEE International Conference on Data Mining, 435-442, 2003. .. [2] C. Elkan, "The foundations of Cost-Sensitive Learning", in Seventeenth International Joint Conference on Artificial Intelligence, 973-978, 2001. Examples -------- 0.12454256594 0.192480226286 0.465830173459 0.466630646543 75653 109975 8690 10191 0.0668182358928 0.358054103205 0.436939010357 0.49602590521 """


    #TODO: Check consistency of input

    # The methods are construct only for the misclassification costs, not the full cost matrix.
    cost_mis = cost_mat[:, 0]
    cost_mis[y == 1] = cost_mat[y == 1, 1]

    # wc = cost_mis / cost_mis.max()
    wc = np.minimum(cost_mis / np.percentile(cost_mis, max_wc), 1)

    n_samples = X.shape[0]

    filter_ = list(range(n_samples))

    if method == 'RejectionSampling':
        # under-sampling by rejection [1]
        #TODO: Add random state
        rej_rand = np.random.rand(n_samples)

        filter_ = rej_rand <= wc

    elif method == 'OverSampling':
        # over-sampling with normalized wn [2]
        wc_n = np.ceil(wc / oversampling_norm).astype(np.int)

        new_n = wc_n.sum()

        filter_ = np.ones(new_n, dtype=np.int)

        e = 0
        #TODO replace for
        for i in range(n_samples):
            filter_[e: e + wc_n[i]] = i
            e += wc_n[i]

    x_cps = X[filter_]
    y_cps = y[filter_]
    cost_mat_cps = cost_mat[filter_]

    return x_cps, y_cps, cost_mat_cps