CMSC_828C_Project1/Bayes_PCA.py
def run_pca(train_data, test_data):
    """
    This function performs PCA on data set and reduces its dimensionality
    :param train_data: train data for PCA dimensionality reduction
    :param test_data: test data for PCA dimensionality reduction
    :return: train and test data after applying PCA
    """
    pca = PCA()
    pca.fit(train_data)
    cumsum = np.cumsum(pca.explained_variance_ratio_)
    d = np.argmax(cumsum >= 0.95) + 1
    print("no. of dimensions: ", d)
    pca = PCA(n_components=187)
    x_train_pca = pca.fit_transform(train_data)
    x_test_pca = pca.fit_transform(test_data)

    return x_train_pca, x_test_pca

    This function performs PCA on data set and reduces its dimensionality
    :param train_data: train data for PCA dimensionality reduction
    :param test_data: test data for PCA dimensionality reduction
    :return: train and test data after applying PCA
    
This function performs PCA on data set and reduces its dimensionality
This function performs PCA on data set and reduces its dimensionality
def run_pca(train_data, test_data):
    pca = PCA()
    pca.fit(train_data)
    cumsum = np.cumsum(pca.explained_variance_ratio_)
    d = np.argmax(cumsum >= 0.95) + 1
    print("no. of dimensions: ", d)
    pca = PCA(n_components=187)
    x_train_pca = pca.fit_transform(train_data)
    x_test_pca = pca.fit_transform(test_data)
    return x_train_pca, x_test_pca
def run_pca ( train_data , test_data ) : pca = PCA ( ) pca . fit ( train_data ) cumsum = np . cumsum ( pca . explained_variance_ratio_ ) d = np . argmax ( cumsum >= 0.95 ) + 1 print ( "no. of dimensions: " , d ) pca = PCA ( n_components = 187 ) x_train_pca = pca . fit_transform ( train_data ) x_test_pca = pca . fit_transform ( test_data ) return x_train_pca , x_test_pca
This function performs PCA on data set and reduces its dimensionality
This function performs PCA on data set and reduces its dimensionality
"""
    This function performs PCA on data set and reduces its dimensionality
    :param train_data: train data for PCA dimensionality reduction
    :param test_data: test data for PCA dimensionality reduction
    :return: train and test data after applying PCA
    """
train and test data after applying PCA
train and test data after applying PCA
train_data
train data for PCA dimensionality reduction
train data for PCA dimensionality reduction
test_data
test data for PCA dimensionality reduction
test data for PCA dimensionality reduction