titanic survival 2
来源:互联网 发布:华大基因 大数据 编辑:程序博客网 时间:2024/04/18 03:48
#########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]
- titanic survival 2
- titanic survival 1
- kaggle之Predict survival on the Titanic
- Survival
- Survival
- Titanic
- kaggle实例学习-Titanic(2)
- SURVIVAL SHOOTER TUTORIAL之Player Character [2]
- Survival analysis
- Kaggle:Titanic问题(2)——实现代码
- kaggle-titanic top 2%初体验之特征工程
- POJ2354-Titanic
- titanic prediction
- 【kaggle】Titanic
- Kaggle: Titanic
- kaggle:titanic
- titanic+tensorflow
- kaggle-Titanic
- LeetCode之操作两个数相除DivideTwoIntegers
- jQuery html() 方法
- oracle不提供CREATE TABLE IF NOT EXIST方式创建表
- UML类图与类的关系
- usaco 2.4 fractions to decimails
- titanic survival 2
- js注册在标签上的点击事件
- Ordered dithering
- 多余元素删除之移位算法
- web安全(入门篇)
- 伪静态配置开启
- linux下查看所有登录用户的历史操作命令
- Flex 布局教程:语法篇
- Wifi密码破解1:通过字典(暴力)破解WIFI密码