首页
社区
课程
招聘
[原创]人工智能竞赛_泰坦尼克生存率预测
2022-1-6 17:21 26829

[原创]人工智能竞赛_泰坦尼克生存率预测

2022-1-6 17:21
26829

前言

最近搞了个kaggle的比赛,感觉是一个很好的入门的案例,在此记录一下

比赛链接:https://www.kaggle.com/c/titanic

环境:vsCode+jupyter notebook


题目内容

图表信息

这道题本身比较基础,比赛题目的意思是需要从train.csv文件中找到乘客生存率与乘客信息之间的关联并进行训练,将训练后的结果对test.csv中的乘客进行预测,判断test表中的乘客的生存几率

train.csv文件内容大致如下图

test.csv内容大致如下图

可以看到test.csv里的乘客少了Servived这一项数据


我的思路

这是一个简单的二分类任务,因为生存的结果就只有两个,活着和死去(应该是没有既活着又死去的情况吧),我的想法是直接用随机森林来做预测

随机森林是众多二分类模型乃至所有人工智能模型中最简单易懂的模型之一了,随机森林由许多决策树组成,决策树的结构如下图所示

树中的内容并不重要,重要的是数的判断方式,这种判断方式比较符合人类的判断方式,决策树最终会输出一个bool值来表示结果,而随机森林就是将许多个决策树放在一起,并统计最终的结果

因此随机森林模型的结构应当如下图所示

随机森林的优点是不容易过拟合且训练速度很快,缺点也很明显,因为所有特征都会被用作判断标准,所以如果数据中有许多权值不高的特征的话会影响模型的精度

我的最终代码如下

# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
# 加载sklearn的随机森林模型
from sklearn.ensemble import RandomForestClassifier
# Input data files are available in the read-only "../input/" directory
# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory
import os
for dirname, _, filenames in os.walk('./input'):
    for filename in filenames:
        print(os.path.join(dirname, filename))
# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using "Save & Run All"
# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session

# 打印train.csv的部分数据
train_data=pd.read_csv("./input/train.csv")
train_data.head()

# 打印test.csv的部分数据
test_data=pd.read_csv("./input/test.csv")
test_data.head()

# 获取乘客幸存数据
y=train_data['Survived']

# 获取乘客其他数据
features=['Pclass','Sex','SibSp','Parch']
X=pd.get_dummies(train_data[features])
X_test=pd.get_dummies(test_data[features])

# 创建随机森林模型
# n_estimators:模型中决策树的数量
# max_depth:决策树的最大深度
# random_state:随机数生成器使用的种子
model=RandomForestClassifier(n_estimators=100,max_depth=5,random_state=1)
# 训练模型
model.fit(X,y)
predictions=model.predict(X_test)

# 将预测的结果以csv文件形式保存
output=pd.DataFrame({'PassengerId':test_data.PassengerId,'Survived':predictions})
print(output)
output.to_csv("./output/submission.csv",index=False)
print("数据已保存!")

结果保存后直接提交

分数只有0.77(满分是1),似乎训练的结果并不是很好,此时需要参考一下大神的代码


大神的代码

第一位

这位大神的代码是满分,而且点赞也比较多,说明还对自己的代码做了解释,我对代码进行了一些翻译(只翻译了重要部分的代码,并重点理解了代码的重要部分)

# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
# Input data files are available in the read-only "../input/" directory
# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory
import os
for dirname, _, filenames in os.walk('./input'):
    for filename in filenames:
        print(os.path.join(dirname, filename))
# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using "Save & Run All"
# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session

import seaborn as sns
from sklearn.metrics import accuracy_score
from sklearn import preprocessing
from sklearn.model_selection import train_test_split
from sklearn.model_selection import cross_val_score
from sklearn.ensemble import RandomForestClassifier
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.linear_model import SGDClassifier
from sklearn.svm import SVC

train_path = "./input/train.csv"
test_path  = "./input/test.csv"
train = pd.read_csv(train_path)
test = pd.read_csv(test_path)

#Some info about the data
train.info()
print('--------')
print('Percentage of NA per property sorted')
print('--------')
p = (train.isna().sum()/len(train)*100).sort_values(ascending=False)
print(p)
print('--------')
print('Unique values for duplications and other useful info')
print('--------')
u = train.nunique().sort_values()
print(u)

# 检查Embarked值,以便进行手动替换
train['Embarked'].value_counts()

#######################################################################
# 对数据中缺失的信息进行处理
# 参数:
# data:缺失了部分数据的数据表
#
# 返回值:
# data:经过处理后的数据表
#######################################################################
def cleanData(data):
   
    # 部分项目缺失的太多,无法补足,所以舍弃
    data.drop(['Cabin','Name','Ticket'], axis=1, inplace=True)
    # 补足年龄的缺失
    data['Age'] = data.groupby(['Pclass','Sex'])['Age'].transform(lambda x: x.fillna(x.median()))
   
    # 补足test数据集中的票价信息
    data['Fare'] = data.groupby(['Pclass','Sex'])['Fare'].transform(lambda x: x.fillna(x.median()))
    # 登船信息虽然缺失很少,但是这项数据本身意义不大,所以舍弃
    data.dropna(axis=0, subset=['Embarked'], inplace=True)
   
    # Categorical Data
    le = preprocessing.LabelEncoder()
   
    # Sex
    data['Sex'].replace({'male':0, 'female':1}, inplace=True)
   
    # Embarked
    data['Embarked'].replace({'S':0, 'C':1, 'Q':2}, inplace=True)
   
    return data


clean_train = cleanData(train)
clean_test = cleanData(test)

# Set X and y
y = train['Survived']
X = pd.get_dummies(train.drop('Survived', axis=1))

# Split model train test data
X_train, X_val, y_train, y_val = train_test_split(X,y, test_size=0.2, random_state=42)

#######################################################################
# 训练模型并返回模型精确度
# 参数:
# model:选定的模型
#
# 返回值:
# accuracy_score(y_val, prediction):模型精确度
#######################################################################
def fitAndPredict(model):
    model.fit(X_train, y_train)
    prediction = model.predict(X_val)
    return accuracy_score(y_val, prediction)

# 逻辑回归
model1 = LogisticRegression(solver='liblinear', random_state=42)

# 梯度提升决策树
model2 = GradientBoostingClassifier()

# 随机森林
model3 = RandomForestClassifier()

# 随机梯度下降
model4 = SGDClassifier()

# C-支持向量分类器
model5 = SVC()
models = [model1, model2, model3, model4, model5]
i = 0

# 对指定的模型进行训练并打印精确度
for model in models:
    i +=1
    print("Model ", i,":", model)
    print("ACC: ", fitAndPredict(model))

# 梯度提升决策树是表现比较好的一个模型,我们加一些超参数,并进行训练
model = GradientBoostingClassifier(min_samples_split=20, min_samples_leaf=60, max_depth=3, max_features=7)
fitAndPredict(model)

# 使用训练好的数据对
predict = model.predict(pd.get_dummies(clean_test))
output = pd.DataFrame({'PassengerId': clean_test.PassengerId, 'Survived': predict})
print(output)
#output.to_csv('my_submission.csv', index=False)
print("Submission saved")

可见这位大佬对不同模型的精确度进行了对比,需要说明的是,二分类大致有两种做法,第一种就是我自己用的随机森林,第二种是逻辑回归;随机森林的返回结果就只有两个,要么True,要么False;而逻辑回归的返回结果是一个概率,准确的说是一个介于0和1之间的数,最后会判断这个值是更接近0还是更接近1;

继续看一个大神开发的代码,他的代码得到的赞是最多的

第二位

此人的代码点赞是最多的,基本上可以说是我读过的人工智能项目入门最好的代码了

# data analysis and wrangling
import pandas as pd
import numpy as np
import random as rnd
# visualization
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['font.sans-serif'] = ['SimHei']  
# Matplotlib中设置字体-黑体,解决Matplotlib中文乱码问题
plt.rcParams['axes.unicode_minus'] = False    
# 解决Matplotlib坐标轴负号'-'显示为方块的问题
# machine learning

from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC, LinearSVC
from sklearn.ensemble import RandomForestClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn.linear_model import Perceptron
from sklearn.linear_model import SGDClassifier
from sklearn.tree import DecisionTreeClassifier
train_df = pd.read_csv('./input/train.csv')
test_df = pd.read_csv('./input/test.csv')
combine = [train_df, test_df]
print(train_df.columns.values)

# preview the data
train_df.head()
train_df.tail()
train_df.info()
print('_'*40)
test_df.info()
train_df.describe()
# Review survived rate using `percentiles=[.61, .62]` knowing our problem description mentions 38% survival rate.
# Review Parch distribution using `percentiles=[.75, .8]`
# SibSp distribution `[.68, .69]`
# Age and Fare `[.1, .2, .3, .4, .5, .6, .7, .8, .9, .99]`

train_df.describe(include=['O'])

# 打印出社会等级(Pclass)和幸存率之间的关系
train_df[['Pclass', 'Survived']].groupby(['Pclass'], as_index=False).mean().sort_values(by='Survived', ascending=False)

# 打印出性别(Sex)和幸存率之间的关系
train_df[["Sex", "Survived"]].groupby(['Sex'], as_index=False).mean().sort_values(by='Survived', ascending=False)

# 打印出SibSp和幸存率之间的关系
train_df[["SibSp", "Survived"]].groupby(['SibSp'], as_index=False).mean().sort_values(by='Survived', ascending=False)

# 打印出Parch和幸存率之间的关系
train_df[["Parch", "Survived"]].groupby(['Parch'], as_index=False).mean().sort_values(by='Survived', ascending=False)

# 图表打印出年龄(Age)和幸存率之间的关系
g = sns.FacetGrid(train_df, col='Survived')
g.map(plt.hist, 'Age', bins=20)

# 图表打印出社会等级(Pclass)和幸存率之间的关系
# grid = sns.FacetGrid(train_df, col='Pclass', hue='Survived')
grid = sns.FacetGrid(train_df, col='Survived', row='Pclass', size=2.2, aspect=1.6)
grid.map(plt.hist, 'Age', alpha=.5, bins=20)
grid.add_legend()

# 图表打印出不同Embarked下不同性别和幸存率之间的关系
# grid = sns.FacetGrid(train_df, col='Embarked')
grid = sns.FacetGrid(train_df, row='Embarked', size=2.2, aspect=1.6)
grid.map(sns.pointplot, 'Pclass', 'Survived', 'Sex', palette='deep')
grid.add_legend()

# 将分类特征和数字特征关联起来,结果表明支付票价较高的乘客生存率更高,乘船的位置也决定了乘客的生存率
# grid = sns.FacetGrid(train_df, col='Embarked', hue='Survived', palette={0: 'k', 1: 'w'})
grid = sns.FacetGrid(train_df, row='Embarked', col='Survived', size=2.2, aspect=1.6)
grid.map(sns.barplot, 'Sex', 'Fare', alpha=.5, ci=None)
grid.add_legend()

# 放弃部分对生存率影响不大的数据
print("Before", train_df.shape, test_df.shape, combine[0].shape, combine[1].shape)
train_df = train_df.drop(['Ticket', 'Cabin'], axis=1)
test_df = test_df.drop(['Ticket', 'Cabin'], axis=1)
combine = [train_df, test_df]
"After", train_df.shape, test_df.shape, combine[0].shape, combine[1].shape
for dataset in combine:
    dataset['Title'] = dataset.Name.str.extract(' ([A-Za-z]+)\.', expand=False)
pd.crosstab(train_df['Title'], train_df['Sex'])

# 对数据特征进行修改,以便分类
for dataset in combine:
    dataset['Title'] = dataset['Title'].replace(['Lady', 'Countess','Capt', 'Col',\
    'Don', 'Dr', 'Major', 'Rev', 'Sir', 'Jonkheer', 'Dona'], 'Rare')
    dataset['Title'] = dataset['Title'].replace('Mlle', 'Miss')
    dataset['Title'] = dataset['Title'].replace('Ms', 'Miss')
    dataset['Title'] = dataset['Title'].replace('Mme', 'Mrs')
   
train_df[['Title', 'Survived']].groupby(['Title'], as_index=False).mean()
title_mapping = {"Mr": 1, "Miss": 2, "Mrs": 3, "Master": 4, "Rare": 5}
for dataset in combine:
    dataset['Title'] = dataset['Title'].map(title_mapping)
    dataset['Title'] = dataset['Title'].fillna(0)
train_df.head()

# 对信息进行补全后就可以丢弃一些无关紧要的信息了
train_df = train_df.drop(['Name', 'PassengerId'], axis=1)
test_df = test_df.drop(['Name'], axis=1)
combine = [train_df, test_df]
train_df.shape, test_df.shape

# 将性别(Sex)特征转换为female和male
for dataset in combine:
    dataset['Sex'] = dataset['Sex'].map( {'female': 1, 'male': 0} ).astype(int)
train_df.head()

# 用图表显示出不同年龄、不同性别和不同社会等级之间的分布情况
# grid = sns.FacetGrid(train_df, col='Pclass', hue='Gender')
grid = sns.FacetGrid(train_df, row='Pclass', col='Sex', size=2.2, aspect=1.6)
grid.map(plt.hist, 'Age', alpha=.5, bins=20)
grid.add_legend()
guess_ages = np.zeros((2,3))
guess_ages

# 更新迭代年龄值
for dataset in combine:
    for i in range(0, 2):
        for j in range(0, 3):
            guess_df = dataset[(dataset['Sex'] == i) & \
                                  (dataset['Pclass'] == j+1)]['Age'].dropna()
            # age_mean = guess_df.mean()
            # age_std = guess_df.std()
            # age_guess = rnd.uniform(age_mean - age_std, age_mean + age_std)
            age_guess = guess_df.median()
            # Convert random age float to nearest .5 age
            guess_ages[i,j] = int( age_guess/0.5 + 0.5 ) * 0.5
           
    for i in range(0, 2):
        for j in range(0, 3):
            dataset.loc[ (dataset.Age.isnull()) & (dataset.Sex == i) & (dataset.Pclass == j+1),\
                    'Age'] = guess_ages[i,j]
    dataset['Age'] = dataset['Age'].astype(int)
train_df.head()

# 找出年龄与幸存率之间的关系
train_df['AgeBand'] = pd.cut(train_df['Age'], 5)
train_df[['AgeBand', 'Survived']].groupby(['AgeBand'], as_index=False).mean().sort_values(by='AgeBand', ascending=True)

# 将具体的年龄转换为年龄区间
for dataset in combine:    
    dataset.loc[ dataset['Age'] <= 16, 'Age'] = 0
    dataset.loc[(dataset['Age'] > 16) & (dataset['Age'] <= 32), 'Age'] = 1
    dataset.loc[(dataset['Age'] > 32) & (dataset['Age'] <= 48), 'Age'] = 2
    dataset.loc[(dataset['Age'] > 48) & (dataset['Age'] <= 64), 'Age'] = 3
    dataset.loc[ dataset['Age'] > 64, 'Age']
train_df.head()
train_df = train_df.drop(['AgeBand'], axis=1)
combine = [train_df, test_df]
train_df.head()

# 将SibSp和Parch这两个特征合并为FamilySize
for dataset in combine:
    dataset['FamilySize'] = dataset['SibSp'] + dataset['Parch'] + 1
train_df[['FamilySize', 'Survived']].groupby(['FamilySize'], as_index=False).mean().sort_values(by='Survived', ascending=False)

# 创建一个新特征:是否一个人(IsAlone)
for dataset in combine:
    dataset['IsAlone'] = 0
    dataset.loc[dataset['FamilySize'] == 1, 'IsAlone'] = 1
train_df[['IsAlone', 'Survived']].groupby(['IsAlone'], as_index=False).mean()

# 舍弃Parch、SibSp和FamilySize特征,只保留IsAlone特征
train_df = train_df.drop(['Parch', 'SibSp', 'FamilySize'], axis=1)
test_df = test_df.drop(['Parch', 'SibSp', 'FamilySize'], axis=1)
combine = [train_df, test_df]
train_df.head()
for dataset in combine:
    dataset['Age*Class'] = dataset.Age * dataset.Pclass
train_df.loc[:, ['Age*Class', 'Age', 'Pclass']].head(10)
freq_port = train_df.Embarked.dropna().mode()[0]
freq_port

# 填补Embarked的缺失
for dataset in combine:
    dataset['Embarked'] = dataset['Embarked'].fillna(freq_port)
   
train_df[['Embarked', 'Survived']].groupby(['Embarked'], as_index=False).mean().sort_values(by='Survived', ascending=False)

# 用数字代替原始Embarked的值
for dataset in combine:
    dataset['Embarked'] = dataset['Embarked'].map( {'S': 0, 'C': 1, 'Q': 2} ).astype(int)
train_df.head()

# 对test数据集的票价(Fare)特征进行处理,获得该特征出现频率最高的值
test_df['Fare'].fillna(test_df['Fare'].dropna().median(), inplace=True)
test_df.head()
train_df['FareBand'] = pd.qcut(train_df['Fare'], 4)
train_df[['FareBand', 'Survived']].groupby(['FareBand'], as_index=False).mean().sort_values(by='FareBand', ascending=True)

# 将具体的票价改为票价区间段
for dataset in combine:
    dataset.loc[ dataset['Fare'] <= 7.91, 'Fare'] = 0
    dataset.loc[(dataset['Fare'] > 7.91) & (dataset['Fare'] <= 14.454), 'Fare'] = 1
    dataset.loc[(dataset['Fare'] > 14.454) & (dataset['Fare'] <= 31), 'Fare']   = 2
    dataset.loc[ dataset['Fare'] > 31, 'Fare'] = 3
    dataset['Fare'] = dataset['Fare'].astype(int)
train_df = train_df.drop(['FareBand'], axis=1)
combine = [train_df, test_df]
   
train_df.head(10)
test_df.head(10)
X_train = train_df.drop("Survived", axis=1)
Y_train = train_df["Survived"]
X_test  = test_df.drop("PassengerId", axis=1).copy()
X_train.shape, Y_train.shape, X_test.shape

# 使用逻辑回归进行训练并打印出模型训练精度
logreg = LogisticRegression()
logreg.fit(X_train, Y_train)
Y_pred = logreg.predict(X_test)
acc_log = round(logreg.score(X_train, Y_train) * 100, 2)
acc_log

# 从逻辑回归的训练结果来看,性别(Sex)的增长(男性为0,女性为1)与幸存率的增长成正比
# 而社会等级(Pclass)的增长(1级为最高,3级为最低)与幸存率的增长成反比
coeff_df = pd.DataFrame(train_df.columns.delete(0))
coeff_df.columns = ['Feature']
coeff_df["Correlation"] = pd.Series(logreg.coef_[0])
coeff_df.sort_values(by='Correlation', ascending=False)

# 使用支持向量机进行训练并打印出模型训练精度
svc = SVC()
svc.fit(X_train, Y_train)
Y_pred = svc.predict(X_test)
acc_svc = round(svc.score(X_train, Y_train) * 100, 2)
acc_svc

# 使用K-临近算法进行训练并打印出模型训练精度
knn = KNeighborsClassifier(n_neighbors = 3)
knn.fit(X_train, Y_train)
Y_pred = knn.predict(X_test)
acc_knn = round(knn.score(X_train, Y_train) * 100, 2)
acc_knn

# 使用朴素贝叶斯分类器进行训练并打印出模型训练精度
gaussian = GaussianNB()
gaussian.fit(X_train, Y_train)
Y_pred = gaussian.predict(X_test)
acc_gaussian = round(gaussian.score(X_train, Y_train) * 100, 2)
acc_gaussian

# 使用感知机进行训练并打印出模型训练精度
perceptron = Perceptron()
perceptron.fit(X_train, Y_train)
Y_pred = perceptron.predict(X_test)
acc_perceptron = round(perceptron.score(X_train, Y_train) * 100, 2)
acc_perceptron

# 使用线性支持向量机进行训练并打印出模型训练精度
linear_svc = LinearSVC()
linear_svc.fit(X_train, Y_train)
Y_pred = linear_svc.predict(X_test)
acc_linear_svc = round(linear_svc.score(X_train, Y_train) * 100, 2)
acc_linear_svc

# 使用随机梯度下降进行训练并打印出模型训练精度
sgd = SGDClassifier()
sgd.fit(X_train, Y_train)
Y_pred = sgd.predict(X_test)
acc_sgd = round(sgd.score(X_train, Y_train) * 100, 2)
acc_sgd

# 使用决策树进行训练并打印出模型训练精度
decision_tree = DecisionTreeClassifier()
decision_tree.fit(X_train, Y_train)
Y_pred = decision_tree.predict(X_test)
acc_decision_tree = round(decision_tree.score(X_train, Y_train) * 100, 2)
acc_decision_tree

# 使用随机森林进行训练并打印出模型训练精度
random_forest = RandomForestClassifier(n_estimators=100)
random_forest.fit(X_train, Y_train)
Y_pred = random_forest.predict(X_test)
random_forest.score(X_train, Y_train)
acc_random_forest = round(random_forest.score(X_train, Y_train) * 100, 2)
acc_random_forest

# 对比以上用到的模型,发现随机森林和决策树这两种模型在本次测试中精确度最高
# 但是最终我们还是会选择随机森林,因为单一的决策树训练时容易过拟合
models = pd.DataFrame({
    'Model': ['Support Vector Machines', 'KNN', 'Logistic Regression',
              'Random Forest', 'Naive Bayes', 'Perceptron',
              'Stochastic Gradient Decent', 'Linear SVC',
              'Decision Tree'],
    'Score': [acc_svc, acc_knn, acc_log,
              acc_random_forest, acc_gaussian, acc_perceptron,
              acc_sgd, acc_linear_svc, acc_decision_tree]})
models.sort_values(by='Score', ascending=False)
submission = pd.DataFrame({
        "PassengerId": test_df["PassengerId"],
        "Survived": Y_pred
    })
# submission.to_csv('../output/submission.csv', index=False)

可以看到代码最开始用表格和图表的方式展示了各个特征和幸存率之间的关系,并且对杂乱无章的特征进行了归类,舍弃了一些关系不大的特征,这些手工分析看似很low,其实在我刚开始学习人工智能时老师就说过不要觉得手工分析很低级,因为在代码的预测能力还没有达到人类的误差之前,使用手工分析是可以大大提升代码的预测准确度的;而后使用多个模型进行训练(这和第二段代码是一样的),其实这两个人的代码都有一个问题,那就是没有详细介绍模型的超参数是如何设置的,然而事实上训练数据并不是很庞大,超参数的调整可能对模型精确度并没有很大的影响


结尾

代码使用jupyter notebook写的,在这里看有点儿怪,源代码我会上传到附件,这是本人第一次接触类似的比赛,如有不足之处,请斧正


[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法

最后于 2022-1-6 17:23 被pureGavin编辑 ,原因: 错字
上传的附件:
收藏
点赞4
打赏
分享
最新回复 (15)
雪    币: 12755
活跃值: (16292)
能力值: (RANK:730 )
在线值:
发帖
回帖
粉丝
有毒 10 2022-1-6 17:29
2
0
这很有意思啊!
雪    币: 12050
活跃值: (15369)
能力值: ( LV12,RANK:240 )
在线值:
发帖
回帖
粉丝
pureGavin 2 2022-1-6 17:40
3
0
有毒 这很有意思啊!
居然得到毒哥的认可了!
雪    币: 12755
活跃值: (16292)
能力值: (RANK:730 )
在线值:
发帖
回帖
粉丝
有毒 10 2022-1-6 19:34
4
0
pureGavin 居然得到毒哥的认可了!
别骂了别骂了,这个内容我真的不熟,就觉得很好玩
雪    币: 17473
活跃值: (5241)
能力值: ( LV15,RANK:880 )
在线值:
发帖
回帖
粉丝
obaby 20 2022-1-6 20:12
5
0

这个我也做过,尝试了不同的方法。不过效果吗,比大神的差远了

雪    币: 7986
活跃值: (5190)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
mudebug 2022-1-7 06:59
6
0
喜欢这种主题文章
雪    币: 12050
活跃值: (15369)
能力值: ( LV12,RANK:240 )
在线值:
发帖
回帖
粉丝
pureGavin 2 2022-1-7 09:31
7
0
obaby 这个我也做过,尝试了不同的方法。不过效果吗,比大神的差远了
怎么也不贴一下你的代码,我感觉分数之所以提不上去,就是因为有些与幸存率无关的数据比如passengerID也被当做特征算进去了,随机森林对这种有无关特征的样本就容易过拟合
雪    币: 17473
活跃值: (5241)
能力值: ( LV15,RANK:880 )
在线值:
发帖
回帖
粉丝
obaby 20 2022-1-7 09:53
8
0
pureGavin 怎么也不贴一下你的代码,我感觉分数之所以提不上去,就是因为有些与幸存率无关的数据比如passengerID也被当做特征算进去了,随机森林对这种有无关特征的样本就容易过拟合
是的,数据清洗和特征选择挺关键的。给的数据本身纬度不少但是缺失数据较多,缺失数据的补充也是个技术活。http://h4ck.org.cn/2019/11/%E5%9F%BA%E4%BA%8Erandomforestclassifier%E7%9A%84titanic%E7%94%9F%E5%AD%98%E6%A6%82%E7%8E%87%E5%88%86%E6%9E%90/ 代码现在手上没有,直接提个我的blog链接吧
雪    币: 12050
活跃值: (15369)
能力值: ( LV12,RANK:240 )
在线值:
发帖
回帖
粉丝
pureGavin 2 2022-1-7 10:26
9
0
obaby 是的,数据清洗和特征选择挺关键的。给的数据本身纬度不少但是缺失数据较多,缺失数据的补充也是个技术活。http://h4ck.org.cn/2019/11/%E5%9F%BA%E4%BA%8Erando ...
大佬牛逼,带带我可以吗
雪    币: 17473
活跃值: (5241)
能力值: ( LV15,RANK:880 )
在线值:
发帖
回帖
粉丝
obaby 20 2022-1-7 10:30
10
0
pureGavin 大佬牛逼,带带我可以吗

大佬,表酱紫~~我也是菜到起飞啊,业余爱好干这个,与实际干这个的水平差的太多了。可不敢害人啊~~

最后于 2022-1-7 10:31 被obaby编辑 ,原因:
雪    币: 22393
活跃值: (25272)
能力值: ( LV15,RANK:910 )
在线值:
发帖
回帖
粉丝
1900 6 2022-1-17 09:48
11
0
为啥不用Pytorch或者tf
雪    币: 12050
活跃值: (15369)
能力值: ( LV12,RANK:240 )
在线值:
发帖
回帖
粉丝
pureGavin 2 2022-1-18 09:27
12
0
1900 为啥不用Pytorch或者tf
杀鸡焉用牛刀
雪    币: 663
活跃值: (504)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
月明呀 2022-1-23 13:00
13
0
我一直想问下,这是一个中专生的水平?兄弟,方便问下你多大了吗
雪    币: 12050
活跃值: (15369)
能力值: ( LV12,RANK:240 )
在线值:
发帖
回帖
粉丝
pureGavin 2 2022-1-24 08:56
14
0
月明呀 我一直想问下,这是一个中专生的水平?兄弟,方便问下你多大了吗
22,有什么问题么?
雪    币: 10
活跃值: (708)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
ugui 2022-2-7 11:18
15
0
有自己代码 有例子代码 挺好的 期待后续更多
雪    币: 12050
活跃值: (15369)
能力值: ( LV12,RANK:240 )
在线值:
发帖
回帖
粉丝
pureGavin 2 2022-2-9 10:22
16
0
ugui 有自己代码 有例子代码 挺好的 期待后续更多
后续不一定能发出来了,一直在搞得北京大学的一个竞赛,自动驾驶的目标识别,感觉问题有点儿大,有部分函数的运算过程看不懂…… 然后现在只能恶补数学知识了
游客
登录 | 注册 方可回帖
返回