Пример #1
0
from machine_learning.prototypes.sgp import sgp
from machine_learning.utils.evaluate import get_acertion_tax
from machine_learning.utils.database_loader import load_database
import sys

if __name__ == '__main__':

	database = 'glass'	
	if len(sys.argv) > 1:
		database = sys.argv[2]

	test = load_database('databases/'+ database + '.test')
	training = load_database('databases/'+ database + '.train')
	
	prototypes = sgp(training)

	print 'tamanho da base original %d' % (len(training))
	print 'tamanho da base pos-sqp  %d' % (len(prototypes))

	print 'taxa de acerto'
	print get_acertion_tax(1, test, prototypes)





Пример #2
0
	
	args =  sys.argv
	optlist, args = getopt.getopt(sys.argv[1:],'d:a:w:e:l:', ['generate-prototypes','help'])
	optlist = dict(optlist)

	if optlist.has_key('--help'):
		print 'help, I need somebody, help, not just anybody, help'
		exit(0)

	database = optlist.get('-d')
	alpha = float(optlist.get('-a'))
	window = float(optlist.get('-w'))
	epsilon = float(optlist.get('-e')) 
	limit = float(optlist.get('-l'))

	training = load_database('databases/' + database + ".train")
	test = load_database('databases/' + database + ".test")
	
	range_vector = get_range_vector([e[:-1] for e in training])

	prototypes = []
	if not optlist.has_key('--generate-prototypes'):
		prototypes = load_database('databases' + database + '.lqvprototypes')
	
	if (len(prototypes) == 0):
		prototypes = generate_prototypes(training)
		f = open('databases/' + database + '.lvqprototypes','w')
		for e in prototypes:
			for a in e:
				f.write(str(a) + '\t')
			f.write('\n')