def testAccuracyKEquals4(self):
     correct, total, accuracy = computeAccuracy(self.distances,
                                                self.consumer_labels,
                                                self.shop_labels,
                                                k=4)
     self.assertEqual((correct, total, accuracy), (3, 3, 1))
예제 #2
0
print("Loaded model from disk")

DATA_DIR = './img_npy_final_features_only/DRESSES/Skirt/'

consumer_features = np.load(DATA_DIR + 'consumer_ResNet50_features.npy')
consumer_labels = np.load(DATA_DIR + 'consumer_labels.npy')
shop_features = np.load(DATA_DIR + 'shop_ResNet50_features.npy')
shop_labels = np.load(DATA_DIR + 'shop_labels.npy')

print (consumer_features.shape)
print (consumer_labels.shape)
print (shop_features.shape)
print (shop_labels.shape)

metrics = [DistanceMetrics.L1] #, DistanceMetrics.L2
top_k = [3,10,20,30,40,50]

for metric in metrics:
		print ("Metric: {}".format(metric))


		accuracies = computeAccuracy(consumer_features,
												   shop_features,
												   consumer_labels,
												   shop_labels,
												   metric = metric,
												   model = model,
												   k = top_k)

		print(accuracies)
예제 #3
0
            preds = [1 if p > 0.5 else 0 for p in preds]
            print("accuracy on batch:", accuracy_score(target, preds))
            print(confusion_matrix(target, preds))
            print(
                precision_recall_fscore_support(target,
                                                preds,
                                                average='weighted'))

            print("Finished batch {} of {}".format(batch_iter, num_batches))
            batch_iter += 1

    print("Printing train set accuracy")
    computeAccuracy(consumer_features,
                    shop_features,
                    consumer_labels,
                    shop_labels,
                    metric=metric,
                    model=model,
                    k=[10, 20, 30])

    print("Printing test set acuracy")
    computeAccuracy(test_consumer_features,
                    shop_features,
                    test_consumer_labels,
                    shop_labels,
                    metric=metric,
                    model=model,
                    k=[10, 20, 30])

    if (SAVE_MODEL):
        model_json = model.to_json()