Kaggle系列(一):Spaceship Titanic(太空飞船泰坦尼克)

开坑开坑Kaggle系列(通过kaggel练习机器学习与数据分析能力)

2022年3月9日,这是第一个版本的太空泰坦尼克任务

我的Github中发布了本任务包含的相应源码与思路分析讲解,欢迎来⭐。

本文主要记录如何对数据进行分析的过程。

开始开始!!!

----------------------------------------------------------分割线--------------------------------------------------------------

首先我们对数据进行下载

由于可能产生的版权或者一系列的问题,就不将数据集放置在此。

你可以从kaggle的网站上下载数据集。url:Spaceship Titanic | Kaggle

"""从官网摘录的字段描述 from Spaceship Titanic | Kaggle"""

""" train.csv - Personal records for about two-thirds (~8700) of the passengers, to be used as training data.

PassengerId - A unique Id for each passenger. Each Id takes the form gggg_pp where gggg indicates a group the passenger is travelling with and pp is their number within the group. People in a group are often family members, but not always.(乘客的ID 共由六位数字组成,前四位为团队编号,代表可能为一同参加的旅行)

HomePlanet - The planet the passenger departed from, typically their planet of permanent residence.(乘客所属母星)

CryoSleep - Indicates whether the passenger elected to be put into suspended animation for the duration of the voyage. Passengers in cryosleep are confined to their cabins.(是否处于休眠状态)

Cabin - The cabin number where the passenger is staying. Takes the form deck/num/side, where side can be either P for Port or S for Starboard.(乘客的床铺位置)

Destination - The planet the passenger will be debarking to.(乘客目的地)

Age - The age of the passenger.(乘客年龄)

VIP - Whether the passenger has paid for special VIP service during the voyage.(乘客是否为VIP客户)

RoomService, FoodCourt, ShoppingMall, Spa, VRDeck - Amount the passenger has billed at each of the Spaceship Titanic's many luxury amenities.(乘客在船上各类的消费数量) Name - The first and last names of the passenger.(乘客姓名)

Transported - Whether the passenger was transported to another dimension. This is the target, the column you are trying to predict.(乘客是否进入异次元空间)

test.csv - Personal records for the remaining one-third (~4300) of the passengers, to be used as test data. Your task is to predict the value of Transported for the passengers in this set.(测试集除了不提供Transported属性外,其他与训练集相同) """

数据集中包含训练集,测试集与示例提交样本(未进行摘录)。训练集与测试集中的样本属性相同且在某些特定属性中含有缺失值。

首先我们假设所有属性均独立,所以我们需要对各属性是否对乘客进入异次元空间有影响做出分析。

我们分析了“乘客一同参加的旅行团队的成员数量find_connection_in id.py”,“乘客所属母星find_connection_in HomePlanet.py”,“是否处于休眠状态find_connection_in cryosleep.py”,“乘客目的地find_connection_in destination.py”,“乘客是否为VIP客户find_connection_in VIP.py”属性对于乘客是否进入异次元空间的影响。

运行find_connection_in id.py我们得到:

此处说明乘客一同参加的旅行团队的成员数量与乘客是否进入异次元空间有一定影响

运行find_connection_in HomePlanet.py我们得到:

此处说明乘客所属母星与乘客是否进入异次元空间有一定影响

运行find_connection_in cryosleep.py我们得到:

此处说明乘客是否处于休眠状态与乘客是否进入异次元空间有大量影响

运行find_connection_in destination.py我们得到:

此处说明乘客目的地与乘客是否进入异次元空间有一定影响

运行find_connection_in VIP.py我们得到:

此处说明乘客是否为VIP客户与乘客是否进入异次元空间有一定影响

年龄属性:有着较好区分人物的效果,且数值方便处理,所以决定加入训练属性中。

消费金额的五个属性:通过将训练集中的部分拆分为验证集的方法,并加入这五个属性进行验证性训练(find_connection_in consumption.py),我们发现损失值大大降低,并且这五个属性中都为消费金额,为可直接处理的连续值,虽然在数据集中含有缺失数据的情况,但均将缺失数据赋值为0进行训练。

而最终本实验共训练11/12个属性:HomePlanet(将原星球使用0/1/2代替)&& CryoSleep(不做处理)&& Destination(将目的地星球使用0/1/2代替)&& Age(不做处理)&& VIP(不做处理)&& RoomService, FoodCourt, ShoppingMall, Spa, VRDeck(消费金额,不做处理)。选择性使用旅行团队的成员数量属性进行训练(因为发现效果不佳,预计可能需要与姓名属性相配合才能达到更好的效果)

______________________________以上为数据分析部分_______________________________

___________________________以下为训练以及数据处理部分___________________________

此任务本人选用随机森林方法进行训练(因为比较方便哈哈哈哈,也是第一次在kaggle上没有寻找参考仅靠自我分析数据与构建模型,虽然最后仅获得score:0.78115,但是毕竟梦想才刚刚开始嘛对吧)

randomforest.py为随机森林训练代码(可采用不同属性进行尝试虽然kaggle每天只给10次提交机会)

create_members.py为生成团队人数信息代码

以上提到的python文件的源码均在我的GitHub/Kaggle/spaceship-titanic项目中。

  • 2
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值