Exemple #1
0
def selectBestModel(project_file, results_model_file):
    f = open(results_model_file + '.results.html', 'w')

    project = yaml.load(open(project_file, 'r'))
    className = project['className']
    results_dir = project['resultsDirectory']

    if os.path.exists(results_dir):
        classifierType = None # all types

        cr = ClassificationResults()
        print 'Loading all results...'
        cr.readResults(results_dir)

        accuracy, filename, params = cr.best(1, classifierType)[0]
        print "RESULT " + project_file + '\t' + str(accuracy) + '\t' + filename

        f.write('<h1>%s (%s)</h1>\nAccuracy: %s\n' % (className, project_file, accuracy))

        cm = ConfusionMatrix()
        cm.load(filename)
        f.write(cm.toHtml())

        filename = filename.replace('.result', '.param')

        trainSVMHistory(project_file, filename, results_model_file, className)
        shutil.copyfile(filename, results_model_file + '.param')

    else:
        print "RESULT " + "No results found for ", project_file, ": cannot build a model"
        f.write('<h1>%s (%s) </h1>\nResults not found\n' % (collection, project_file))
Exemple #2
0
def selectBestModel(project_file, results_model_file):
    f = open(results_model_file + '.results.html', 'w')

    project = yaml.load(open(project_file, 'r'))
    className = project['className']
    results_dir = project['resultsDirectory']

    if os.path.exists(results_dir):
        classifierType = None  # all types

        cr = ClassificationResults()
        print('Loading all results...')
        cr.readResults(results_dir)

        accuracy, filename, params = cr.best(1, classifierType)[0]
        print("RESULT " + project_file + '\t' + str(accuracy) + '\t' +
              filename)

        f.write('<h1>%s (%s)</h1>\nAccuracy: %s\n' %
                (className, project_file, accuracy))

        cm = ConfusionMatrix()
        cm.load(filename)
        f.write(cm.toHtml())

        filename = filename.replace('.result', '.param')

        trainSVMHistory(project_file, filename, results_model_file, className)
        shutil.copyfile(filename, results_model_file + '.param')

    else:
        print("RESULT " + "No results found for ", project_file,
              ": cannot build a model")
        f.write('<h1>%s (%s) </h1>\nResults not found\n' %
                (collection, project_file))
Exemple #3
0
def selectBestModel():

    parser = OptionParser(
        usage='%prog [options] project_file results_model_file')

    options, args = parser.parse_args()

    try:
        project_file = args[0]
        results_model_file = args[1]
    except:
        parser.print_help()
        sys.exit(1)

    f = open(results_model_file + '.results.html', 'w')

    project = yaml.load(open(project_file, 'r'))
    className = project['className']
    results_dir = project['resultsDirectory']

    if os.path.exists(results_dir):
        classifierType = None  # all types

        cr = ClassificationResults()
        print 'Loading all results...'
        cr.readResults(results_dir)

        accuracy, filename, params = cr.best(1, classifierType)[0]
        print "RESULT " + project_file + '\t' + str(accuracy) + '\t' + filename

        f.write('<h1>%s (%s)</h1>\nAccuracy: %s\n' %
                (className, project_file, accuracy))

        cm = ConfusionMatrix()
        cm.load(filename)
        f.write(cm.toHtml())

        filename = filename.replace('.result', '.param')

        trainSVMHistory(project_file, filename, results_model_file, className)
        shutil.copyfile(filename, results_model_file + '.param')

    else:
        print "RESULT " + "No results found for ", project_file, ": cannot build a model"
        f.write('<h1>%s (%s) </h1>\nResults not found\n' %
                (collection, project_file))
Exemple #4
0
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation (FSF), either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the Affero GNU General Public License     
# version 3 along with this program. If not, see http://www.gnu.org/licenses/


from __future__ import print_function
import sys
from gaia2.classification import ConfusionMatrix


try:
    results = sys.argv[1]
    output_html = sys.argv[2]
except:
    print('Usage: %s <results_file> <confusion_matrix_html_file>' % sys.argv[0])
    exit(1)

cm = ConfusionMatrix()
cm.load(results)
open(output_html, 'w').write(cm.toHtml())


# Gaia is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation (FSF), either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the Affero GNU General Public License     
# version 3 along with this program. If not, see http://www.gnu.org/licenses/


import sys
from gaia2.classification import ConfusionMatrix


try:
    results = sys.argv[1]
    output_html = sys.argv[2]
except:
    print 'Usage: %s <results_file> <confusion_matrix_html_file>' % sys.argv[0]
    exit(1)

cm = ConfusionMatrix()
cm.load(results)
open(output_html, 'w').write(cm.toHtml())