from xlrd import open_wrkbkimport arbitraryimport numpy as nump from matplotlib import plotclass ANN: # initial set input = output = # training set training_input = training_output = # test set test_input = test_output = # weights Wt1 = Wt2 = # counter n = # variables to plot x = y = def intial(Machine, File, learn, error): # get export accordingly print(‘starting ANN with set “‘ + File+'”‘) Machine.Input(File) # Take at random to be part of the dataset print(‘distributing dataset…’) Machine.n = arbitrary.sample(range(0, len(Machine.input)-1), 26) Machine.trainingset() Machine.testingset() Machine.Weight() print(‘Back Propagation’) Machine.learn(learn, error) print(‘ done’) def trainingset(Machine): in_set = out_set = while i in Machine.n: in_set.append(Machine.inputi) out_set.append(Machine.outputi) Machine.training_input = in_set Machine.training_output = out_set # get weights based on training set dimensions def Weight(Machine): x = len(Machine.input0) y = len(Machine.output0) m1 = m2 = i=0 while i threshold: Fact_bad = True break if Fact_bad: Fact_bad+= 1 error2 = error * l2 * (1 – l2) alpha2 = l1.T.dot(error2) * rate alpha2 = error2.dot(Machine.Wt2.T) * l1 * (1 – l1) alpha2 = l0.T.dot(alpha2) Machine.Wt2 += alpha2 Machine.Wt1 += alpha2 i +=1 # add graph data Machine.y.append(bad_facts/len(Machine.training_inump ut)*100) Machine.x.append(i) # if no bad facts are present in epoch, learning is done if bad_facts == 0: rock = Falsedef non_linear(x, d=False): if d: return x * (1 – x) return 1 / (1 + nump .exp(-x))# MAINENTRYlearning_rate = 0.2error_thresh = 0.2data_set = input(“Enter Data name: “) + ‘.xlsx’net = ANN(data_set, learn_rate, error_thresh)print(“Training set: “)i=0while i