(instruction, dataset, target="", y="")
return data_modified, accuracy_score(
        clf.predict(X_test), y_test), max(acc), (len(
            dataset.columns) - len(data_modified.columns))
function to reduce dimensionality in dataset via kernal principal component analysis
    :param instruction: command sent to client instance in written query.
    :param dataset: data instantiated in client instance passed to the algorithm
    :param target: column name of response variable/feature
    :param y: dictionary of train/test data values associated with response variable/feature
function to reduce dimensionality in dataset via kernal principal component analysis
    :param instruction: command sent to client instance in written query.
    :param dataset: data instantiated in client instance passed to the algorithm
    :param target: column name of response variable/feature
    :param y: dictionary of train/test data values associated with response variable/feature
function to reduce dimensionality in dataset via kernal principal component analysis : param instruction : command sent to client instance in written query . : param dataset : data instantiated in client instance passed to the algorithm : param target : column name of response variable / feature : param y : dictionary of train / test data values associated with response variable / feature
def dimensionality_KPCA(instruction, dataset, target="", y=""):
    '''
    function to reduce dimensionality in dataset via kernal principal component analysis
    :param instruction: command sent to client instance in written query.
    :param dataset: data instantiated in client instance passed to the algorithm
    :param target: column name of response variable/feature
    :param y: dictionary of train/test data values associated with response variable/feature
    '''
    
    pca = KernelPCA(kernel='rbf')

    dataReader = DataReader(dataset)
    dataset = dataReader.data_generator()

    data, y, target, full_pipeline = initial_preprocessor(
        dataset, instruction, True, 0.2, [], 0.2, random_state=49)


    X_train = data['train']
    X_test = data['test']

    y_train = y['train']
    y_test = y['test']

    X_train_mod = pca.fit_transform(X_train)
    X_test_mod = pca.transform(X_test)

    clf = tree.DecisionTreeClassifier()
    clf_mod = tree.DecisionTreeClassifier()

    clf.fit(X_train, y_train)
    clf_mod.fit(X_train_mod, y_train)

    acc = []
    acc.append(accuracy_score(
        clf_mod.predict(X_test_mod), y_test))

    for i, j in product(range(3, 10), ["entropy", "gini"]):
        model = tree.DecisionTreeClassifier(criterion=j, max_depth=i)
        model = model.fit(X_train_mod, y_train)
        acc.append(accuracy_score(model.predict(X_test_mod), y_test))
    del i, j

    data_modified = pd.concat(
        [pd.DataFrame(X_train_mod), pd.DataFrame(X_test_mod)], axis=0)

    y_combined = np.r_[y_train, y_test]
    data_modified[target] = y_combined
    # data_modified.to_csv("./data/housingPCA.csv")

    return data_modified, accuracy_score(
        clf.predict(X_test), y_test), max(acc), (len(
            dataset.columns) - len(data_modified.columns))
def dimensionality_KPCA ( instruction , dataset , target = "" , y = "" ) : pca = KernelPCA ( kernel = 'rbf' ) dataReader = DataReader ( dataset ) dataset = dataReader . data_generator ( ) data , y , target , full_pipeline = initial_preprocessor ( dataset , instruction , True , 0.2 , [ ] , 0.2 , random_state = 49 ) X_train = data [ 'train' ] X_test = data [ 'test' ] y_train = y [ 'train' ] y_test = y [ 'test' ] X_train_mod = pca . fit_transform ( X_train ) X_test_mod = pca . transform ( X_test ) clf = tree . DecisionTreeClassifier ( ) clf_mod = tree . DecisionTreeClassifier ( ) clf . fit ( X_train , y_train ) clf_mod . fit ( X_train_mod , y_train ) acc = [ ] acc . append ( accuracy_score ( clf_mod . predict ( X_test_mod ) , y_test ) ) for i , j in product ( range ( 3 , 10 ) , [ "entropy" , "gini" ] ) : model = tree . DecisionTreeClassifier ( criterion = j , max_depth = i ) model = model . fit ( X_train_mod , y_train ) acc . append ( accuracy_score ( model . predict ( X_test_mod ) , y_test ) ) del i , j data_modified = pd . concat ( [ pd . DataFrame ( X_train_mod ) , pd . DataFrame ( X_test_mod ) ] , axis = 0 ) y_combined = np . r_ [ y_train , y_test ] data_modified [ target ] = y_combined # data_modified.to_csv("./data/housingPCA.csv") return data_modified , accuracy_score ( clf . predict ( X_test ) , y_test ) , max ( acc ) , ( len ( dataset . columns ) - len ( data_modified . columns ) )