import sys sys.path.append("..") import utility.Util as Util credit_data = Util.open_file("../data/credit_data.csv") # create lists of types of features numerical = ["Duration", 'InstallmentRatePecnt', 'PresentResidenceTime', 'Age'] # categorical = ["CheckingAcctStat", "CreditHistory", "Purpose", 'Savings', 'Employment', 'Property', 'Telephone'] target = ['CreditStatus'] positive_class, negative_class = Util.decompose_classes( credit_data, 'CreditStatus') # get numerical, categorical and labels for each class positive_numerical, positive_target = Util.pre_process_data( positive_class, numerical, target) negative_numerical, negative_target = Util.pre_process_data( negative_class, numerical, target) # cluster data and get cluster labels positive_cluster = Util.cluster_data( positive_numerical) # .join(positive_categorical) negative_cluster = Util.cluster_data(negative_numerical) negative_cluster = np.array([x + 3 for x in negative_cluster]) # give the new cluster label column a name positive_cluster_labels = pd.DataFrame(positive_cluster, columns=['Cluster Label']) negative_cluster_labels = pd.DataFrame(negative_cluster, columns=['Cluster Label'])
import tensorflow as tf import numpy as np import sys sys.path.append("..") import utility.Util as Util credit_data = Util.open_file("../data/credit_data.csv") # create lists of types of features numerical = ["Duration", 'InstallmentRatePecnt', 'PresentResidenceTime', 'Age'] target = ['CreditStatus'] credit_data = credit_data.sample(frac=1).reset_index(drop=True) train_x, train_y = Util.pre_process_data(credit_data, numerical, target) # dividing the dataset into training and test sets x_train, y_train, x_test, y_test = Util.split_data(0.8, train_x, train_y) n_hidden_1 = 8 n_input = train_x.shape[1] n_classes = train_y.shape[1] weights = { 'h1': tf.Variable(tf.random_normal([n_input, n_hidden_1])), 'out': tf.Variable(tf.random_normal([n_hidden_1, n_classes])) } biases = { 'b1': tf.Variable(tf.random_normal([n_hidden_1])), 'out': tf.Variable(tf.random_normal([n_classes])) }