Ask Your Question

Classifying Landscape Features with MLTestSuite

asked 2012-08-08 04:47:05 -0500

anonymous user


kscottz gave me swift response, but I will take it broader: I want to use SimpleCV for landscape feature classification. I am using Windows Vista. I took the MLTestSuite by kscottz from github. Why I am using MLTestSuite:

  1. It performs classification using different ML classifiers within a single script run

  2. the .zip file containing image folders and subfolders is exactly structured in a feasible way for me. Folders: structured + unstructured, each of those contains subfolders with feature images, e.g. cactus, basket etc...

  3. the way the scripts are provided allow a "swift" classification, as well in single ML classifier mode e.g, just in KNN or SVM


  • I am able to import a subfolder containing images, BUT I am NOT able to import .zip file from my local path with a similar structure as the MLTestSuite .zip file. Is there any workaround on this issue?
  • Is it possible to export ML-SVM results for each ML classifier into a .txt file?

Any other suggestions/ideas are welcome!


from SimpleCV import *

print ""
print "This program runs a list of test for machine learning on"
print "the SimpleCV library. Not all scores will be high, this"
print "is just to ensure that the libraries are functioning correctly"
print "on your system"
print ""
print "***** WARNING *****"
print "This program is about to download a large data set to run it's test"

`inp = raw_input("Do you want to continue [Y/n]")

if not (inp == "" or inp.lower() == "y"):
    print "Exiting the program"

#define local .zip file path/How to define a local .zip file path?
machine_learning_data_set = "local/path/"
data_path = download_and_extract(machine_learning_data_set)
print data_path
w = 800
h = 600

display = Display(resolution = (w,h))

hue = HueHistogramFeatureExtractor(mNBins=16)
edge = EdgeHistogramFeatureExtractor()
bof = BOFFeatureExtractor()
haar = HaarLikeFeatureExtractor(fname="../Features/haar.txt")
morph = MorphologyFeatureExtractor()
# load images files according to local .zip file folders (structured and unstructured) 
spath = data_path + "/data/structured/"            
upath = data_path + "/data/unstructured/"

# load files according to local .zip file (-> in structured folder) path        
pier_path = spath+"pier/"
port_path = spath+"port/"
beach_path = spath+"beach/"
sea_path = spath +"sea/"

# load images from .zip files (-> in unstructured folder) 
folderh1_path = upath+"folderh1/"                
folderh2_path = upath+"footbah2/"
folderh12_path = upath+"folderh12/"                

#Set up am SVM with a poly kernel
extractors = [hue]
path = [pier_path,port_path,beach_path,sea_path]
classes = ['pier','port','beach','sea']

props ={
        'KernelType':'RBF', #default is a RBF Kernel
        'SVMType':'C', #default is C
        'nu':None, # NU for SVM NU
        'c':None, #C for SVM C - the slack variable
        'degree':3, #degree for poly kernels - defaults to 3
        'coef':None, #coef for Poly/Sigmoid defaults to 0
        'gamma':None, #kernel param for poly/rbf/sigma - default is 1/#samples
    classifierSVMP = SVMClassifier(extractors,props)
    classifierSVMP.train(path,classes,disp=display,subset=n) #train
    [pos,neg,confuse] = classifierSVMP.test(path,classes,disp=display,subset=n)
    files = []
    for ext in IMAGE_FORMATS:
            files.extend(glob.glob( os.path.join(path[0], ext)))
    for i in range(10):
            img = Image(files[i])
            cname = classifierSVMP ...
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-08-08 09:23:02 -0500

kscottz gravatar image

Importing zip files will be some functionality that you will have to write yourself. If you fork the repo and want to add this functionality back to the library send us a pull request. The download and extract function lives in SimpleCV/SimpleCV/ (FYI -- I used downloadandextract.func_code in the command line to find this information out).

As for exporting SVM data you are more or less on your own. Our ML library basically wraps the Orange data mining library, which I think in turn wraps LibSVM. I would refer to those libraries functionality to determine if exporting to text file is possible.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-08-08 04:47:05 -0500

Seen: 285 times

Last updated: Aug 08 '12