#########hte idea is to create an table which contains just 1's and 0's.The array will be a surbibal reference table.whereby you read in the
##########tet data,find out passenger attributes,look them opn in the survival table,and determine if they should be predicted to survive or not.
######In hte case of a model that use gender,calss,and ticktet price,you will need an array of 2X3X4([female/male],[1st/2nd/3rd class],[4bins
############of bprices]).The script will systematically will loop through each combination and use the "where" function in python to search
######passengers that fit that combination of variables.Just like befor,you can ask what indices in your data equals female,1st class,and paid
#########more than $30.For the sake of binning let's say everything equal to and abouve 40 "equals" 39 so it falls in this bin.So then you can
######set the bins:
#######so we add a ceiling
fare_ceiling=40
######then modify the data in the fare column to=39,if it is greater or equal to the ciling
data[data[0::,9].astype(np.float)>=fare_ceiling,9]=fare_ceiling-1.0
####I know there were 1st,2nd adn 3rd classes on board
number_of_classes=3
#####but it is better practice to calculate this from the data directly
####take the length of an array of unique valuese in column index2
number_of_classes=len(np.unique(data[0::,2]))
######initialize the survival table with all zeros
survival_table=np.zeros((2,number_of_classes,number_of_price_brackets))
######now that these are set up,you can loop throuhg each variable and find all those passengers that agree with the statements:
for i in xrange(number_of_classes): ##########loop through each class
for j in xrange(number_of_price_brackets): ########loop through each price bin
women_only_stats=data[ \######which element
(data[0::,4]=="femalse") \######is a female
&(data[0::,2].astype(np.float) \######and wa ith class
==i+1)\
&(data[0:,9].astype(np.float)) \######## was greater
>=j*fare_bracket_size \#######than this bin
&(data[0:,9].astype(np.float) \#######and less than
<=(j+1)*fare_bracket_size) \#####the next bin
,1] \#####in the 2nde col
men_only_stats=data[(data[0::,4]!="female") \#####is a male
&(data[0::,2].astype(np.float)) \#########and was ith class
==i+1
&(data[0:,9].astype(np.float) \#############was greater
>=j*fare_bracket_size) \############than this bin
& (data[0:,9].astype(np.float) \############and less than
<(j+1)*fare_bracket_size) \#########the next bin
,1]