def evaluate(self, afile): f2b = File2Buffer() f2b.file_load(afile) index_of_max_value = tf.argmax(self.hypothesis, 1) hit_record = tf.equal(index_of_max_value, tf.argmax(self.Y_one_hot, 1)) recognition_rate = tf.reduce_mean(tf.cast(hit_record, tf.float32)) # acc = self.sess.run(recognition_rate, feed_dict={ self.X: f2b.x_data, self.Y: f2b.y_data }) print("Acc: {:.2%}".format(acc * 100))
def evaluate_file_one_hot(self, afile, num_of_class): f2b = File2Buffer() f2b.file_load(afile) Y_one_hot_reshaped = self.Y_2_one_hot(f2b.y_data, num_of_class) index = tf.argmax(self.hypothesis, 1) # op for returning index of a max value correct_prediction = tf.equal(index, tf.argmax(Y_one_hot_reshaped, 1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) acc = self.sess.run(accuracy, feed_dict={ self.X: f2b.x_data, self.Y: f2b.y_data }) print("Acc: {:.2%}".format(acc))
def learn_with_file(self, afile, total_loop, check_step): f2b = File2Buffer() f2b.file_load(afile) #print(f2b.x_data, f2b.y_data) self.learn(f2b.x_data, f2b.y_data, total_loop, check_step)
def load_file(self, afile): f2b = File2Buffer() f2b.file_load(afile) return f2b.x_data, f2b.y_data
def learn_from_file(self, afile, total_loop, check_step): f2b = File2Buffer() f2b.file_load(afile) #f2b.print_info() self.learn(f2b.x_data, f2b.y_data, total_loop, check_step)
output = tf.sigmoid(output) self.set_hypothesis(output) self.set_cost_function(NNType.LOGISTIC) self.set_optimizer(NNType.GRADIENT_DESCENT, l_rate=0.01) def my_log(self, i, x_data, y_data): pass gildong = MVLogisticRegression4Diabetes() gildong.learn_with_file('data-03-diabetes.csv', 10000, 200) #10000, 200 gildong.test_sigmoid( [[0.176471, 0.155779, 0, 0, 0, 0.052161, -0.952178, -0.733333]]) f2b = File2Buffer() f2b.file_load('data-03-diabetes.csv') gildong.evaluate_sigmoid(f2b.x_data, f2b.y_data) gildong.show_error() ''' 1200 0.654603 1400 0.640737 1600 0.62813 1800 0.616668 2000 0.606246 [[ 0.6939525]] [ 0.55056906] [ 0.71810943] [ 0.72589421] [ 0.58412576]