Merge branch 'master' of github.com:kstaats/karoo_gp

pull/4/head
Kai Staats 2016-07-07 23:14:02 -06:00
commit 27a9b4f585
5 changed files with 0 additions and 133 deletions

View File

@ -1,5 +0,0 @@
# arithmetic operands
*,2
+,2
-,2
/,2
1 # arithmetic operands
2 *,2
3 +,2
4 -,2
5 /,2

View File

@ -1,5 +0,0 @@
# boolean operands
and,2
or,2
if,3
not,1
1 # boolean operands
2 and,2
3 or,2
4 if,3
5 not,1

View File

@ -1,21 +0,0 @@
# trig operands,
+,2
-,2
*,2
/,2
+,2
-,2
*,2
/,2
+,2
-,2
*,2
/,2
+,2
-,2
*,2
/,2
+ cos,2
- cos,2
* cos,2
/ cos,2
1 # trig operands
2 + 2
3 - 2
4 * 2
5 / 2
6 + 2
7 - 2
8 * 2
9 / 2
10 + 2
11 - 2
12 * 2
13 / 2
14 + 2
15 - 2
16 * 2
17 / 2
18 + cos 2
19 - cos 2
20 * cos 2
21 / cos 2

View File

@ -1,55 +0,0 @@
NATIVE PYTHON OPERATORS
www.tutorialspoint.com/python/python_basic_operators.htm
** Exponentiation (raise to the power)
~ + - Complement, unary plus and minus (method names for the last two are +@ and -@)
* / % // Multiply, divide, modulo and floor division
+ - Addition and subtraction
>> << Right and left bitwise shift
& Bitwise 'AND'td>
^ | Bitwise exclusive `OR' and regular `OR'
<= < > >= Comparison operators
<> == != Equality operators
is is not Identity operators
in not in Membership operators
not or and Logical operators
= %= /= //= -= += *= **= Assignment operators
GP OPERAND GROUPS
(copy / paste into functions.cvs, giving weight through quantity of copies)
+,2
-,2
*,2
/,2
**,2 (not recommended)
and,2 or &,2 ???
or,2 or |,2 ???
not,1 or !,2 ??? # need to get 'not' to not fall at the end
+ sin,2
- sin,2
* sin,2
/ sin,2
+ cos,2
- cos,2
* cos,2
/ cos,2
+ exp,2
- exp,2
* exp,2
/ exp,2
+ sqrt,2
+ sqrt,2
- sqrt,2
/ sqrt,2

View File

@ -1,47 +0,0 @@
# Karoo Feature Set Prep
# Prepare a balanced dataset
# by Kai Staats, MSc UCT / AIMS and Arun Kumar, PhD
import sys
import numpy as np
if len(sys.argv) == 1: print '\n\t\033[31mERROR! You have not assigned an input file. Try again ...\033[0;0m'; sys.exit()
elif len(sys.argv) > 2: print '\n\t\033[31mERROR! You have assigned too many command line arguments. Try again ...\033[0;0m'; sys.exit()
filename = sys.argv[1] # 'data/pixel_classifier/kat7-20150924-SUBSET.csv'
print '\n\t\033[36m You have opted to load the dataset:', filename, '\033[0;0m'
samples = 5000
# do NOT use readline as that is very, very slow
# ideally use 'pandas', a numpy replacement which loads data 5x faster (future version)
# for now, we'll just load the damn data as we have ample RAM
data = np.loadtxt(filename, skiprows = 1, delimiter = ',', dtype = float) #; data_x = data_x[:,0:-1]
# header = need to read the first line to retain the variables
print '\ndata loaded'
print ' data.shape:', data.shape
# find the indices where the final column = 0 or 1 and record the row num accordingly
data_0_list = np.where(data[:,-1] == 0)
data_1_list = np.where(data[:,-1] == 1)
data_0 = np.random.choice(data_0_list[0], samples, replace = False)
data_1 = np.random.choice(data_1_list[0], samples, replace = False)
print '\nrandom, unique rows generated'
print ' data_0.shape:', data_0.shape
print ' data_1.shape:', data_1.shape
print '\nready to merge data_0 and data_1 with real values'
data_0_new = data[data_0]
data_1_new = data[data_1]
data_new = np.vstack((data_0_new, data_1_new))
print ' data_new.shape', data_new.shape
# np.savetxt(fname, X, fmt='%.18e', delimiter=' ', newline='\n', header='', footer='', comments='# ')
# need to append the header
np.savetxt('data_new.csv', data_new, delimiter = ',')
print '\n data saved as data_new.csv'