trn_loss, trn_pred = fis.train(sess, trnData, trnLbls) # Evaluate on validation set val_pred, val_loss = fis.infer(sess, chkData, chkLbls) if epoch % 10 == 0: print("Train cost after epoch %i: %f" % (epoch, trn_loss)) if epoch == num_epochs - 1: time_end = time.time() print("Elapsed time: %f" % (time_end - time_start)) print("Validation loss: %f" % val_loss) # Plot real vs. predicted pred = np.vstack((np.expand_dims(trn_pred, 1), np.expand_dims(val_pred, 1))) plt.figure(1) plt.plot(mg_series) plt.plot(pred) trn_costs.append(trn_loss) val_costs.append(val_loss) # Plot the cost over epochs plt.figure(2) plt.subplot(2, 1, 1) plt.plot(np.squeeze(trn_costs)) plt.title("Training loss, Learning rate =" + str(alpha)) plt.subplot(2, 1, 2) plt.plot(np.squeeze(val_costs)) plt.title("Validation loss, Learning rate =" + str(alpha)) plt.ylabel('Cost') plt.xlabel('Epochs') # Plot resulting membership functions fis.plotmfs(sess) plt.show()
# Run an update step trn_loss, trn_pred = fis.train(sess, trnData, trnLbls) # Evaluate on validation set val_pred, val_loss = fis.infer(sess, chkData, chkLbls) if epoch % 10 == 0: print("Train cost after epoch %i: %f" % (epoch, trn_loss)) if epoch == num_epochs - 1: time_end = time.time() print("Elapsed time: %f" % (time_end - time_start)) print("Validation loss: %f" % val_loss) # Plot real vs. predicted pred = np.vstack((np.expand_dims(trn_pred, 1), np.expand_dims(val_pred, 1))) plt.figure(1) plt.plot(mg_series) plt.plot(pred) trn_costs.append(trn_loss) val_costs.append(val_loss) # Plot the cost over epochs plt.figure(2) plt.subplot(2, 1, 1) plt.plot(np.squeeze(trn_costs)) plt.title("Training loss, Learning rate =" + str(alpha)) plt.subplot(2, 1, 2) plt.plot(np.squeeze(val_costs)) plt.title("Validation loss, Learning rate =" + str(alpha)) plt.ylabel('Cost') plt.xlabel('Epochs') # Plot resulting membership functions fis.plotmfs(sess) plt.show()
if trn_loss > 0.01: continue else: pas = 1 # Plot the cost over epochs plt.figure(2) plt.subplot(2, 1, 1) plt.plot(np.squeeze(trn_costs)) plt.title("Training loss, Learning rate =" + str(alpha)) plt.subplot(2, 1, 2) plt.plot(np.squeeze(val_costs)) plt.title("Validation loss, Learning rate =" + str(alpha)) plt.ylabel('Cost') plt.xlabel('Epochs') # Plot resulting membership functions rule_stats = fis.plotmfs(sess) inp_list = [ "Seniority ", "Propensity ", "Size of Company ", "Contactibility " ] action = "send brochure" for r in rule_stats: if abs(rule_stats[r]["center"]) > 0.05: #print("rule %s" % r) term = "\nrule %s: IF(" % r for inp in range(4): hb = rule_stats[r][inp]["high_bound"] lb = rule_stats[r][inp]["low_bound"] significance = "" if lb >= 1 or hb <= 0: significance = "is not related " elif hb == 1 and lb == 0: significance = "is in any value "