コード例 #1
0
ファイル: karoo_gp.py プロジェクト: ByteSumoLtd/karoo_gp
	-fil [path]/[to]/[data].csv		an external dataset


An example is given, as follows:

	$ python karoo_gp_server.py -ker c -typ r -bas 4 -fil [path]/[to]/[data].csv

'''

import os
import sys
sys.path.append('modules/')  # add directory 'modules' to the current path
import argparse
import karoo_gp_base_class
gp = karoo_gp_base_class.Base_GP()

os.system('clear')
print '\n\033[36m\033[1m'
print '\t **   **   ******    *****    ******    ******       ******    ******'
print '\t **  **   **    **  **   **  **    **  **    **     **        **    **'
print '\t ** **    **    **  **   **  **    **  **    **     **        **    **'
print '\t ****     ********  ******   **    **  **    **     **   ***  *******'
print '\t ** **    **    **  ** **    **    **  **    **     **    **  **'
print '\t **  **   **    **  **  **   **    **  **    **     **    **  **'
print '\t **   **  **    **  **   **  **    **  **    **     **    **  **'
print '\t **    ** **    **  **    **  ******    ******       ******   **'
print '\033[0;0m'
print '\t\033[36m Genetic Programming in Python - by Kai Staats, version 2.1\033[0;0m'
print ''
コード例 #2
0
ファイル: karoo_gp_server.py プロジェクト: falconzyx/karoo_gp
	-ker		[r,c,m]			fitness function: (r)egression, (c)lassification, or (m)atching
	-typ		[f,g,r]			Tree type: (f)ull, (g)row, or (r)amped half/half
	-bas		[3...10]		maximum Tree depth for the initial population
	-max		[3...10]		maximum Tree depth for the entire run
	-min		[3...100]		minimum number of nodes
	-pop		[10...1000]		maximum population
	-gen		[1...100]		number of generations
	
Note that if you include any of the above flags, then you must also include a flag to load an external dataset:

	$ python karoo_gp_server.py -ker c -typ r -bas 4 -fil /[path]/[to_your]/[filename].csv
'''

import sys # sys.path.append('modules/') to add the directory 'modules' to the current path
import argparse
import karoo_gp_base_class; gp = karoo_gp_base_class.Base_GP()

ap = argparse.ArgumentParser(description = 'Karoo GP Server')
ap.add_argument('-ker', action = 'store', dest = 'kernel', default = 'm', help = '[c,r,m] fitness function: (r)egression, (c)lassification, or (m)atching')
ap.add_argument('-typ', action = 'store', dest = 'type', default = 'r', help = '[f,g,r] Tree type: (f)ull, (g)row, or (r)amped half/half')
ap.add_argument('-bas', action = 'store', dest = 'depth_base', default = 3, help = '[3...10] maximum Tree depth for the initial population')
ap.add_argument('-max', action = 'store', dest = 'depth_max', default = 3, help = '[3...10] maximum Tree depth for the entire run')
ap.add_argument('-min', action = 'store', dest = 'depth_min', default = 3, help = '[3...100] minimum number of nodes')
ap.add_argument('-pop', action = 'store', dest = 'pop_max', default = 100, help = '[10...1000] maximum population')
ap.add_argument('-gen', action = 'store', dest = 'gen_max', default = 10, help = '[1...100] number of generations')
ap.add_argument('-fil', action = 'store', dest = 'filename', default = 'files/data_MATCH.csv', help = '/path/to_your/[data].csv')

args = ap.parse_args()

# pass the argparse defaults and/or user inputs to the required variables
gp.kernel = str(args.kernel)