@@ -35,12 +35,17 @@ def features_for(im):
3535sobels = []
3636labels = []
3737
38+ print ('Computing features...' )
3839# Use glob to get all the images
3940images = glob ('{}/*.jpg' .format (basedir ))
4041for fname in images :
4142 haralicks .append (features_for (fname ))
4243 sobels .append (edginess_sobel (mh .imread (fname , as_grey = True )))
43- labels .append (fname [:- len ('00.jpg' )])
44+
45+ # Files are named like building00.jpg, scene23.jpg...
46+ labels .append (fname [:- len ('xx.jpg' )])
47+
48+ print ('Finished computing features.' )
4449
4550haralicks = np .array (haralicks )
4651sobels = np .array (sobels )
@@ -58,3 +63,12 @@ def features_for(im):
5863 LogisticRegression (), haralick_plus_sobel , labels , cv = 5 ).mean ()
5964print ('Accuracy (5 fold x-val) with Logistic Regrssion [std features + sobel]: {}%' .format (
6065 0.1 * round (1000 * scores .mean ())))
66+
67+
68+ # We can try to just use the sobel feature. The result is almost completely
69+ # random.
70+ scores = cross_validation .cross_val_score (
71+ LogisticRegression (), np .atleast_2d (sobels ).T , labels , cv = 5 ).mean ()
72+ print ('Accuracy (5 fold x-val) with Logistic Regrssion [only using sobel feature]: {}%' .format (
73+ 0.1 * round (1000 * scores .mean ())))
74+
0 commit comments