Example #1
0
    def __init__(self, data, file_name=None):
        if (file_name != None):
            data = prepare_for_analysis(file_name)

        self.model = None

        # -- Seperate --
        self.y = data[:, :1]
        scaler = StandardScaler()
        self.X = scaler.fit_transform(data[:, 1:])

        # -- Needs to be retained for inserting new samples
        self.mean = scaler.mean_
        self.scale = scaler.scale_

        self.num_samples, self.num_attributes = self.X.shape

        # -- Split Training/Test --
        self.X_tr = self.X[:int(0.8 * self.num_samples)]
        self.X_test = self.X[int(0.8 * self.num_samples):]

        self.y_tr = self.y[:int(0.8 * self.num_samples)]
        self.y_test = self.y[int(0.8 * self.num_samples):]
Example #2
0
import pandas as pd
import numpy as np
from SVM_model import SVM_model
from ILE import instance_explanation, prepare_for_D3, divide_data_bins
from Functions import prepare_for_analysis

np.random.seed(12345)

vals = pd.read_csv("final_data_file.csv", header=None).values
X = vals[:, 1:]
y = vals[:, 0]

vals_no_9 = prepare_for_analysis("final_data_file.csv")
X_no_9 = vals_no_9[:, 1:]

no_samples, no_features = X.shape

svm_model = SVM_model(None, "final_data_file.csv")
svm_model.train_model(0.001)
svm_model.test_model()

bins_centred, X_pos_array, init_vals = divide_data_bins(X_no_9, [9, 10])

# sample = 2
# print(X[sample])
# print(instance_explanation(svm_model, X, X[sample], sample, X_pos_array, bins_centred))
# print(instance_explanation(svm_model, X, X[sample], sample, X_pos_array, bins_centred))
# print(instance_explanation(svm_model, X, X[sample], sample, X_pos_array, bins_centred))
ANCH_THRESH = 4
CHG_THRESH = 5