PyTorch Tabular技术文档

PyTorch Tabular技术文档

pytorch_tabular A standard framework for modelling Deep Learning Models for tabular data pytorch_tabular 项目地址: https://gitcode.com/gh_mirrors/py/pytorch_tabular

PyTorch Tabular是一款旨在简化深度学习在表格数据应用的库,它设计时考虑到了易用性、可定制性和部署的便捷性。本文档将引导您了解如何安装该库、使用其功能、掌握API详情以及进行项目搭建。

安装指南

基础安装

确保您的系统已预先安装了正确版本的PyTorch。访问PyTorch官方网站选择适合您设备的CUDA版本完成安装。之后,通过以下命令安装PyTorch Tabular的核心功能:

pip install -U "pytorch_tabular"

对于完整体验(包含Weights&Biases和Plotly等额外依赖),执行:

pip install -U "pytorch_tabular[extra]"

源码安装

如果您想要从源代码编译安装,首先通过Git克隆仓库:

git clone git://github.com/manujosephv/pytorch_tabular

进入项目目录并安装(推荐加上[extra]以获得全部依赖):

cd pytorch_tabular && pip install .[extra]

项目使用说明

PyTorch Tabular简化了深度学习模型的构建过程,特别适用于表格型数据。下面是快速使用示例,展示如何配置和训练一个分类模型:

首先,导入必要的模块,并定义数据配置、优化器配置、训练配置以及模型配置:

from pytorch_tabular import TabularModel
from pytorch_tabular.models import CategoryEmbeddingModelConfig
from pytorch_tabular.config import (
    DataConfig,
    OptimizerConfig,
    TrainerConfig,
)

# 配置数据、模型、训练参数等
data_config = DataConfig(target=["目标列名"], continuous_cols, categorical_cols)
optimizer_config = OptimizerConfig()
trainer_config = TrainerConfig(auto_lr_find=True, batch_size=1024, max_epochs=100)
model_config = CategoryEmbeddingModelConfig(task="classification", layers="1024-512-512", activation="LeakyReLU")

# 初始化并训练模型
tabular_model = TabularModel(
    data_config, model_config, optimizer_config, trainer_config
)
tabular_model.fit(train_data, validation_data)
predictions = tabular_model.predict(test_data)

请注意替换持续特征列名类别特征列名目标列名为实际数据集中的对应列名。

项目API使用文档

PyTorch Tabular提供了丰富的API来支持不同的需求,例如:

  • TabularModel: 主接口,用于创建、训练和预测。

    TabularModel(
        data_config, 
        model_config, 
        optimizer_config=None, 
        trainer_config=None, 
        experiment_config=None
    )
    

    其中,data_config指定数据结构,model_config定义网络架构,而optimizer_configtrainer_config分别控制优化器设置和训练流程。

  • DataConfig: 用来定义输入数据的结构,包括连续列和类别列。

  • ModelConfig: 根据不同任务(如分类、回归)设定模型配置,可以定制网络层数、激活函数等。

项目特点和模型

此库支持多种深度学习模型,包括但不限于:

  • FeedForward Network with Category Embedding
  • Neural Oblivious Decision Ensembles (NODE)
  • TabNet
  • Mixture Density Networks
  • AutoInt
  • TabTransformer
  • FT Transformer
  • Gated Adaptive Network for Deep Automated Learning of Features (GANDALF)
  • Deep Abstract Networks (DANETs)
  • 还有支持半监督学习的Denoising AutoEncoder。

每个模型都有其特定的应用场景和优势,用户可根据实际需求选择合适的模型配置。

以上是PyTorch Tabular的基础使用和技术概览,更多详细信息和高级教程,请查阅官方文档

pytorch_tabular A standard framework for modelling Deep Learning Models for tabular data pytorch_tabular 项目地址: https://gitcode.com/gh_mirrors/py/pytorch_tabular

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

窦萍娴Prudent

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值