pytorch回归_PyTorch:用岭回归检查泰坦尼克号下沉

pytorch回归

In this notebook, we shall use this dataset containing data about passengers from the Titanic. Based on this data, we will use a Ridge Regression model which just means a Logistic Regression model that uses L2 Regularization for predicting whether a person survived the sinking based on their passenger class, sex, the number of their siblings/spouses aboard, the number of their parents/children aboard and the fare they payed.

在这款笔记本上,我们将使用这种含有大约从泰坦尼克号的乘客数据集。 基于此数据,我们将使用Ridge回归模型,该模型仅表示使用L2正则化的Logistic回归模型,根据乘客的等级,性别,同胞/配偶的人数,人数来预测某人是否沉没。他们的父母/孩子和他们支付的车费。

First, we import everything we need for plotting data and creating a great model to make predictions on the data.

首先,我们导入绘制数据和创建出色模型以对数据进行预测所需的一切。

数据探索 (Data Exploration)

Here, we can see what the data actually looks like. The first column indicates whether the person survived with a 1 or a 0, where the 1 stands for survival and the 0 for death. The rest of the columns are all our input columns used to predict the survival. We will, however, forget about as it does not hold important information needed to predict survival. You can also see below that we have 887 persons with their data and 8 total columns where 6 of them will be the input values and 1 of them (the Survived column) the corresponding label.

在这里,我们可以看到数据的实际外观。 第一列表示该人是生存还是生存1或0,其中1代表生存,0代表死亡。 其余的列都是我们用来预测生存率的所有输入列。 但是,我们将忘记它,因为它不具备预测生存所需的重要信息。 您还可以在下面看到,我们有887个人及其数据,共有8列,其中6个为输入值,其中1个(生存列)为相应的标签。

To get a little bit more familiar with the data we can do some computations with it and plot it. First we print how big the part of the survivors is which can also be described as the total probability of survival.

为了更熟悉数据,我们可以对其进行一些计算并绘制出图表。 首先,我们打印幸存者部分的大小,这也可以描述为生存的总概率。

When we look at how likely different people from different classes and of different sexes are to survive we can see a clear trend that the higher the class the higher the survival probability and also that women are more likely to survive. Ever wondered why is this the case? The answer is quite simple.

当我们观察来自不同阶级和性别的不同人的生存可能性时,我们可以清楚地看到一个趋势,即阶级越高,生存的可能性就越高,而且女性生存的可能性就越大。 有没有想过为什么会这样呢? 答案很简单。

When the Titanic began to sink, women and children would go off-board in the lifeboats first before the men. The lower class passengers were not treated equally at the time of sinking as there were so many people in the lower class that not all could not be informed by the stewardesses. Subsequently, it took much longer for them to get to the deck for rescue while first and second class passengers were already boarding the lifeboats. Also, the sailors fastened down the hatchways leading to the third-class section. They said they wanted to keep the air down there so the vessel could stay up longer. It meant all hope was gone for the passengers still down there.

当泰坦尼克号沉没时,妇女和儿童将首先在救生艇上驶离船上,然后才驶向男子。 在下沉时,下层旅客没有得到同等的对待,因为下层旅客太多,因此乘务员并不能告知所有人。 随后,当头等舱和二等舱乘客已经登上救生艇时,他们花了更长的时间才能到达甲板上进行救援。 此外,水手们将舱口固定在通往三等舱的舱口上。 他们说,他们希望将空气保持在那里,以便船只可以停留更长的时间。 这意味着所有仍在那里的乘客的希望已荡然无存。

Another reason why so many people died was the missing safety measures onboard the Titanic. For example, there were not enough boats for the passengers to escape the ship. The lifeboats would have only been sufficient for half the people onboard and due to bad organization not all of them were completely filled. More than half of the passengers were left behind. One good aspect, however, is that the laws for a ship’s safety have become more strict since this disaster. If you want to read about the sinking in detail, have a look at this: https://en.wikipedia.org/wiki/Sinking_of_the_RMS_Titanic

如此之多的人死亡的另一个原因是泰坦尼克号上缺少安全措施。 例如,没有足够的船只供乘客逃脱。 救生艇仅能满足船上一半人的需要,而且由于组织不善,并非所有人都被完全装满。 一半以上的乘客被抛在后面。 但是,一个好的方面是,自这场灾难以来,船舶安全的法律变得更加严格。 如果您想详细了解下沉,请查看以下内容: https : //en.wikipedia.org/wiki/Sinking_of_the_RMS_Titanic

Looking at the prices, which are all measured in pounds, we can see the total average fare and then the different ones from the different classes. Note that due to inflation these numbers measured in pounds today would be a lot higher.

查看全部以磅为单位的价格,我们可以看到总平均票价,然后是不同类别的票价。 请注意,由于通货膨胀,今天这些以磅为单位的数字会高得多。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值