CMSC_828C_Project1/Bayes_LDA_range.py
def run_LDA(train_data, test_data, y_train, y_test, k):
    """
    This function performs LDA on dataset and reduces its dimensionality
    :param train_data: train data for LDA dimensionality reduction
    :param test_data: test data for LDA dimensionality reduction
    :param y_train: training data labels
    :param y_test: testing data labels
    :return: train and test data with reduced dimensionality
    """
    sc = StandardScaler()
    x_train_scaled = sc.fit_transform(train_data)
    x_test_scaled = sc.transform(test_data)
    
#    lda = LDA()     
#    lda.fit(x_train_scaled, y_train)
#    cumsum = np.cumsum(lda.explained_variance_ratio_)
#    d = np.argmax(cumsum >= 0.99) + 1
#    print("no. of dimensions: ", d)
    
    lda = LDA(n_components= k)
    x_train_LDA = lda.fit_transform(x_train_scaled, y_train)
    x_test_LDA = lda.transform(x_test_scaled)

    return x_train_LDA, x_test_LDA

    This function performs LDA on dataset and reduces its dimensionality
    :param train_data: train data for LDA dimensionality reduction
    :param test_data: test data for LDA dimensionality reduction
    :param y_train: training data labels
    :param y_test: testing data labels
    :return: train and test data with reduced dimensionality
    
This function performs LDA on dataset and reduces its dimensionality
This function performs LDA on dataset and reduces its dimensionality
def run_LDA(train_data, test_data, y_train, y_test, k):
    sc = StandardScaler()
    x_train_scaled = sc.fit_transform(train_data)
    x_test_scaled = sc.transform(test_data)
    lda = LDA(n_components= k)
    x_train_LDA = lda.fit_transform(x_train_scaled, y_train)
    x_test_LDA = lda.transform(x_test_scaled)
    return x_train_LDA, x_test_LDA
def run_LDA ( train_data , test_data , y_train , y_test , k ) : sc = StandardScaler ( ) x_train_scaled = sc . fit_transform ( train_data ) x_test_scaled = sc . transform ( test_data ) lda = LDA ( n_components = k ) x_train_LDA = lda . fit_transform ( x_train_scaled , y_train ) x_test_LDA = lda . transform ( x_test_scaled ) return x_train_LDA , x_test_LDA
This function performs LDA on dataset and reduces its dimensionality
This function performs LDA on dataset and reduces its dimensionality
"""
    This function performs LDA on dataset and reduces its dimensionality
    :param train_data: train data for LDA dimensionality reduction
    :param test_data: test data for LDA dimensionality reduction
    :param y_train: training data labels
    :param y_test: testing data labels
    :return: train and test data with reduced dimensionality
    """ #    lda = LDA()     
 #    lda.fit(x_train_scaled, y_train)
 #    cumsum = np.cumsum(lda.explained_variance_ratio_)
 #    d = np.argmax(cumsum >= 0.99) + 1
 #    print("no. of dimensions: ", d)

train and test data with reduced dimensionality
train and test data with reduced dimensionality
train_data
train data for LDA dimensionality reduction
train data for LDA dimensionality reduction
test_data
test data for LDA dimensionality reduction
test data for LDA dimensionality reduction
y_train
training data labels
training data labels
y_test
testing data labels
testing data labels
k