Ejemplo n.º 1
0
def selectAttibutesGA():
	matrix = csv.readCsvRaw(csv.headered_name_pca_corr)
	num_attributes = len(matrix[0])-1
	if False:
		num_subset = 5
		num_trials = max(100, num_attributes*2)
		results = findBestOfSize(matrix, num_subset, num_trials)
		order = orderByResults(results,num_attributes)
	if True:
		sort_order = [i for i in range(num_attributes)]
		for num_subset in range(5, num_attributes, 5):
			num_trials = max(100, num_attributes*2)
			csv_matrix_name  = csv.makeCsvPath('subset.matrix' +('%03d'%num_subset))
			csv_results_name = csv.makePath('subset.results'+('%03d'%num_subset))
			csv_best_name    = csv.makeCsvPath('subset.best'   +('%03d'%num_subset))
			csv_summary_name  = csv.makeCsvPath('subset.summary'+('%03d'%num_subset))
		
			ordered_matrix = pca.reorderMatrix(matrix, sort_order)
			csv.writeCsv(csv_matrix_name, ordered_matrix)
			
			results = findBestOfSize(ordered_matrix, num_subset, num_trials, csv_summary_name)
			
			sort_order = orderByResults(results,num_attributes)
			#c_x = results[0].columns + [-1]      # include outcome
			#sub_matrix = [[row[i] for i in c_x] for row in ordered_matrix]
			#csv.writeCsv(csv_best_name,sub_matrix, )
			if not is_testing:
				shutil.copyfile(results[0]['csv'],csv_best_name)
				shutil.copyfile(results[0]['results'],csv_results_name)
Ejemplo n.º 2
0
	def reorder(in_cells):
	    return pca.reorderMatrix(in_cells, sort_order)