二元分类(泰坦尼克号)

本示例描述了如何使用 Ludwig 为 kaggle 竞赛训练模型,用于预测乘客在泰坦尼克号灾难中幸存的概率。以下是部分数据示例:

Pclass 性别 年龄 SibSp Parch 票价 是否幸存 登船港口
3 男性 22 1 0 7.2500 0 S
1 女性 38 1 0 71.2833 1 C
3 女性 26 0 0 7.9250 0 S
3 男性 35 0 0 8.0500 0 S

完整数据和列描述可在此处找到。

下载数据后,要使用 Ludwig 在此数据集上训练模型,

ludwig experiment \
  --dataset <PATH_TO_TITANIC_CSV> \
  --config config.yaml

使用 config.yaml

input_features:
    -
        name: Pclass
        type: category
    -
        name: Sex
        type: category
    -
        name: Age
        type: number
        preprocessing:
          missing_value_strategy: fill_with_mean
    -
        name: SibSp
        type: number
    -
        name: Parch
        type: number
    -
        name: Fare
        type: number
        preprocessing:
          missing_value_strategy: fill_with_mean
    -
        name: Embarked
        type: category

output_features:
    -
        name: Survived
        type: binary

通过更精细的特征转换和预处理可以获得更好的结果,但本示例仅旨在展示如何使用 Ludwig 处理此类任务和数据。