{ "cells": [ { "cell_type": "markdown", "source": [ "# Cross-validation\n", "\n", "Cross-validation is required to validate the generalization ability of models, avoid the effect of randomization, etc. Randomization may affect the dataset splitting, model initialization, forward propagation (especially convolution operations), and optimization." ], "metadata": { "collapsed": false, "pycharm": { "name": "#%% md\n" } } }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Using cuda device\n", "Downloading https://archive.ics.uci.edu/static/public/9/auto+mpg.zip to /tmp/tmpnpjgki5b/data/Auto MPG.zip\n", "cylinders is Integer and will be treated as a continuous feature.\n", "model_year is Integer and will be treated as a continuous feature.\n", "origin is Integer and will be treated as a continuous feature.\n", "Unknown values are detected in ['horsepower']. They will be treated as np.nan.\n", "The project will be saved to /tmp/tmpnpjgki5b/output/auto-mpg/2023-09-23-20-37-47-0_UserInputConfig\n", "Dataset size: 238 80 80\n", "Data saved to /tmp/tmpnpjgki5b/output/auto-mpg/2023-09-23-20-37-47-0_UserInputConfig (data.csv and tabular_data.csv).\n" ] } ], "source": [ "import torch\n", "from tabensemb.trainer import Trainer\n", "from tabensemb.model import *\n", "from tabensemb.config import UserConfig\n", "import tabensemb\n", "import os\n", "\n", "device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n", "print(\"Using {} device\".format(device))\n", "\n", "from tempfile import TemporaryDirectory\n", "\n", "temp_path = TemporaryDirectory()\n", "tabensemb.setting[\"default_output_path\"] = os.path.join(temp_path.name, \"output\")\n", "tabensemb.setting[\"default_config_path\"] = os.path.join(temp_path.name, \"configs\")\n", "tabensemb.setting[\"default_data_path\"] = os.path.join(temp_path.name, \"data\")\n", "\n", "trainer = Trainer(device=device)\n", "mpg_columns = [\n", " \"mpg\",\n", " \"cylinders\",\n", " \"displacement\",\n", " \"horsepower\",\n", " \"weight\",\n", " \"acceleration\",\n", " \"model_year\",\n", " \"origin\",\n", " \"car_name\",\n", "]\n", "cfg = UserConfig.from_uci(\"Auto MPG\", column_names=mpg_columns, sep=r\"\\s+\")\n", "trainer.load_config(cfg)\n", "trainer.load_data()\n", "models = [\n", " PytorchTabular(trainer, model_subset=[\"Category Embedding\"]),\n", "]\n", "trainer.add_modelbases(models)" ] }, { "cell_type": "markdown", "source": [ "## K-fold cross-validation\n", "\n", "Some of the data splitters (See \"Using data functionalities\") in `tabensemb` support k-fold cross-validation. To activate k-fold CV, pass the argument `split_type=\"cv\"` to `Trainer.get_leaderboard`. In this case, the ratio of training/validation/testing sets is (k-2):1:1. Here we present an example of a 4-fold CV." ], "metadata": { "collapsed": false, "pycharm": { "name": "#%% md\n" } } }, { "cell_type": "code", "execution_count": 2, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "----------------------------1/4 cv----------------------------\n", "Using previously used data path /tmp/tmpnpjgki5b/data/auto-mpg.csv\n", "Dataset size: 199 99 100\n", "Data saved to /tmp/tmpnpjgki5b/output/auto-mpg/2023-09-23-20-37-47-0_UserInputConfig (data.csv and tabular_data.csv).\n", "\n", "-------------Run PytorchTabular-------------\n", "\n", "Training Category Embedding\n", "Global seed set to 42\n", "2023-09-23 20:37:48,600 - {pytorch_tabular.tabular_model:473} - INFO - Preparing the DataLoaders\n", "2023-09-23 20:37:48,600 - {pytorch_tabular.tabular_datamodule:290} - INFO - Setting up the datamodule for regression task\n", "2023-09-23 20:37:48,610 - {pytorch_tabular.tabular_model:521} - INFO - Preparing the Model: CategoryEmbeddingModel\n", "2023-09-23 20:37:48,621 - {pytorch_tabular.tabular_model:268} - INFO - Preparing the Trainer\n", "/home/xlluo/anaconda3/envs/tabular_ensemble/lib/python3.10/site-packages/pytorch_lightning/trainer/connectors/accelerator_connector.py:589: LightningDeprecationWarning: The Trainer argument `auto_select_gpus` has been deprecated in v1.9.0 and will be removed in v2.0.0. Please use the function `pytorch_lightning.accelerators.find_usable_cuda_devices` instead.\n", " rank_zero_deprecation(\n", "Auto select gpus: [0]\n", "GPU available: True (cuda), used: True\n", "TPU available: False, using: 0 TPU cores\n", "IPU available: False, using: 0 IPUs\n", "HPU available: False, using: 0 HPUs\n", "2023-09-23 20:37:49,693 - {pytorch_tabular.tabular_model:582} - INFO - Training Started\n", "You are using a CUDA device ('NVIDIA GeForce RTX 3090') that has Tensor Cores. To properly utilize them, you should set `torch.set_float32_matmul_precision('medium' | 'high')` which will trade-off precision for performance. For more details, read https://pytorch.org/docs/stable/generated/torch.set_float32_matmul_precision.html#torch.set_float32_matmul_precision\n", "LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]\n", "\n", " | Name | Type | Params\n", "---------------------------------------------------------------\n", "0 | _backbone | CategoryEmbeddingBackbone | 11.4 K\n", "1 | _embedding_layer | Embedding1dLayer | 14 \n", "2 | head | LinearHead | 33 \n", "3 | loss | MSELoss | 0 \n", "---------------------------------------------------------------\n", "11.4 K Trainable params\n", "0 Non-trainable params\n", "11.4 K Total params\n", "0.046 Total estimated model params size (MB)\n", "Epoch: 1/300, Train loss: 659.3594, Val loss: 628.6083, Min val loss: 628.6083, Epoch time: 0.035s.\n", "Epoch: 20/300, Train loss: 341.1675, Val loss: 317.6812, Min val loss: 317.6812, Epoch time: 0.011s.\n", "Epoch: 40/300, Train loss: 90.1501, Val loss: 70.8835, Min val loss: 70.8835, Epoch time: 0.011s.\n", "Epoch: 60/300, Train loss: 44.8901, Val loss: 35.4742, Min val loss: 35.4742, Epoch time: 0.011s.\n", "Epoch: 80/300, Train loss: 35.4699, Val loss: 30.2076, Min val loss: 30.2076, Epoch time: 0.011s.\n", "Epoch: 100/300, Train loss: 28.3062, Val loss: 27.7918, Min val loss: 27.7918, Epoch time: 0.012s.\n", "Epoch: 120/300, Train loss: 22.4722, Val loss: 25.4099, Min val loss: 25.4099, Epoch time: 0.011s.\n", "Epoch: 140/300, Train loss: 23.3103, Val loss: 24.1631, Min val loss: 24.1631, Epoch time: 0.010s.\n", "Epoch: 160/300, Train loss: 18.9331, Val loss: 23.2310, Min val loss: 22.8011, Epoch time: 0.013s.\n", "Epoch: 180/300, Train loss: 17.4051, Val loss: 22.7842, Min val loss: 22.7842, Epoch time: 0.010s.\n", "Epoch: 200/300, Train loss: 15.6233, Val loss: 21.3642, Min val loss: 21.3436, Epoch time: 0.011s.\n", "Epoch: 220/300, Train loss: 16.8699, Val loss: 20.2019, Min val loss: 20.2019, Epoch time: 0.010s.\n", "Epoch: 240/300, Train loss: 14.3514, Val loss: 19.4510, Min val loss: 19.4510, Epoch time: 0.010s.\n", "Epoch: 260/300, Train loss: 16.2243, Val loss: 19.0539, Min val loss: 19.0495, Epoch time: 0.009s.\n", "Epoch: 280/300, Train loss: 12.8429, Val loss: 18.1077, Min val loss: 18.0788, Epoch time: 0.011s.\n", "Epoch: 300/300, Train loss: 14.4400, Val loss: 17.8435, Min val loss: 17.8435, Epoch time: 0.009s.\n", "`Trainer.fit` stopped: `max_epochs=300` reached.\n", "2023-09-23 20:37:55,840 - {pytorch_tabular.tabular_model:584} - INFO - Training the model completed\n", "2023-09-23 20:37:55,841 - {pytorch_tabular.tabular_model:1258} - INFO - Loading the best model\n", "/home/xlluo/anaconda3/envs/tabular_ensemble/lib/python3.10/site-packages/pytorch_lightning/utilities/cloud_io.py:33: LightningDeprecationWarning: `pytorch_lightning.utilities.cloud_io.get_filesystem` has been deprecated in v1.8.0 and will be removed in v2.0.0. Please use `lightning_fabric.utilities.cloud_io.get_filesystem` instead.\n", " rank_zero_deprecation(\n", "Training mse loss: 10.68487\n", "Validation mse loss: 17.84354\n", "Testing mse loss: 9.95495\n", "Trainer saved. To load the trainer, run trainer = load_trainer(path='/tmp/tmpnpjgki5b/output/auto-mpg/2023-09-23-20-37-47-0_UserInputConfig/trainer.pkl')\n", "\n", "-------------PytorchTabular End-------------\n", "\n", "Category Embedding 1/1\n", "--------------------------End 1/4 cv--------------------------\n", "----------------------------2/4 cv----------------------------\n", "Using previously used data path /tmp/tmpnpjgki5b/data/auto-mpg.csv\n", "Dataset size: 199 99 100\n", "Data saved to /tmp/tmpnpjgki5b/output/auto-mpg/2023-09-23-20-37-47-0_UserInputConfig (data.csv and tabular_data.csv).\n", "\n", "-------------Run PytorchTabular-------------\n", "\n", "Training Category Embedding\n", "Global seed set to 42\n", "2023-09-23 20:37:56,591 - {pytorch_tabular.tabular_model:473} - INFO - Preparing the DataLoaders\n", "2023-09-23 20:37:56,592 - {pytorch_tabular.tabular_datamodule:290} - INFO - Setting up the datamodule for regression task\n", "2023-09-23 20:37:56,601 - {pytorch_tabular.tabular_model:521} - INFO - Preparing the Model: CategoryEmbeddingModel\n", "2023-09-23 20:37:56,613 - {pytorch_tabular.tabular_model:268} - INFO - Preparing the Trainer\n", "/home/xlluo/anaconda3/envs/tabular_ensemble/lib/python3.10/site-packages/pytorch_lightning/trainer/connectors/accelerator_connector.py:589: LightningDeprecationWarning: The Trainer argument `auto_select_gpus` has been deprecated in v1.9.0 and will be removed in v2.0.0. Please use the function `pytorch_lightning.accelerators.find_usable_cuda_devices` instead.\n", " rank_zero_deprecation(\n", "Auto select gpus: [0]\n", "GPU available: True (cuda), used: True\n", "TPU available: False, using: 0 TPU cores\n", "IPU available: False, using: 0 IPUs\n", "HPU available: False, using: 0 HPUs\n", "2023-09-23 20:37:56,627 - {pytorch_tabular.tabular_model:582} - INFO - Training Started\n", "You are using a CUDA device ('NVIDIA GeForce RTX 3090') that has Tensor Cores. To properly utilize them, you should set `torch.set_float32_matmul_precision('medium' | 'high')` which will trade-off precision for performance. For more details, read https://pytorch.org/docs/stable/generated/torch.set_float32_matmul_precision.html#torch.set_float32_matmul_precision\n", "LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]\n", "\n", " | Name | Type | Params\n", "---------------------------------------------------------------\n", "0 | _backbone | CategoryEmbeddingBackbone | 11.4 K\n", "1 | _embedding_layer | Embedding1dLayer | 14 \n", "2 | head | LinearHead | 33 \n", "3 | loss | MSELoss | 0 \n", "---------------------------------------------------------------\n", "11.4 K Trainable params\n", "0 Non-trainable params\n", "11.4 K Total params\n", "0.046 Total estimated model params size (MB)\n", "Epoch: 1/300, Train loss: 696.0748, Val loss: 545.8853, Min val loss: 545.8853, Epoch time: 0.012s.\n", "Epoch: 20/300, Train loss: 372.0458, Val loss: 276.3550, Min val loss: 276.3550, Epoch time: 0.014s.\n", "Epoch: 40/300, Train loss: 85.0721, Val loss: 59.3774, Min val loss: 59.3774, Epoch time: 0.013s.\n", "Epoch: 60/300, Train loss: 48.5832, Val loss: 39.0821, Min val loss: 39.0821, Epoch time: 0.017s.\n", "Epoch: 80/300, Train loss: 31.3669, Val loss: 30.6529, Min val loss: 30.6529, Epoch time: 0.015s.\n", "Epoch: 100/300, Train loss: 24.9108, Val loss: 27.0339, Min val loss: 26.9302, Epoch time: 0.009s.\n", "Epoch: 120/300, Train loss: 21.2625, Val loss: 24.2448, Min val loss: 24.2448, Epoch time: 0.012s.\n", "Epoch: 140/300, Train loss: 19.6647, Val loss: 22.5396, Min val loss: 22.5396, Epoch time: 0.009s.\n", "Epoch: 160/300, Train loss: 18.2782, Val loss: 20.3885, Min val loss: 20.3885, Epoch time: 0.014s.\n", "Epoch: 180/300, Train loss: 19.8687, Val loss: 18.9228, Min val loss: 18.9228, Epoch time: 0.013s.\n", "Epoch: 200/300, Train loss: 17.5661, Val loss: 18.1803, Min val loss: 18.1723, Epoch time: 0.010s.\n", "Epoch: 220/300, Train loss: 17.5160, Val loss: 17.2254, Min val loss: 17.2254, Epoch time: 0.018s.\n", "Epoch: 240/300, Train loss: 18.5148, Val loss: 16.5343, Min val loss: 16.5343, Epoch time: 0.013s.\n", "Epoch: 260/300, Train loss: 19.2128, Val loss: 15.7374, Min val loss: 15.7374, Epoch time: 0.011s.\n", "Epoch: 280/300, Train loss: 13.2446, Val loss: 15.1371, Min val loss: 15.1371, Epoch time: 0.011s.\n", "Epoch: 300/300, Train loss: 12.9830, Val loss: 14.6800, Min val loss: 14.4976, Epoch time: 0.018s.\n", "`Trainer.fit` stopped: `max_epochs=300` reached.\n", "2023-09-23 20:38:02,306 - {pytorch_tabular.tabular_model:584} - INFO - Training the model completed\n", "2023-09-23 20:38:02,307 - {pytorch_tabular.tabular_model:1258} - INFO - Loading the best model\n", "/home/xlluo/anaconda3/envs/tabular_ensemble/lib/python3.10/site-packages/pytorch_lightning/utilities/cloud_io.py:33: LightningDeprecationWarning: `pytorch_lightning.utilities.cloud_io.get_filesystem` has been deprecated in v1.8.0 and will be removed in v2.0.0. Please use `lightning_fabric.utilities.cloud_io.get_filesystem` instead.\n", " rank_zero_deprecation(\n", "Training mse loss: 10.70534\n", "Validation mse loss: 14.49761\n", "Testing mse loss: 13.68175\n", "Trainer saved. To load the trainer, run trainer = load_trainer(path='/tmp/tmpnpjgki5b/output/auto-mpg/2023-09-23-20-37-47-0_UserInputConfig/trainer.pkl')\n", "\n", "-------------PytorchTabular End-------------\n", "\n", "Category Embedding 1/1\n", "--------------------------End 2/4 cv--------------------------\n", "----------------------------3/4 cv----------------------------\n", "Using previously used data path /tmp/tmpnpjgki5b/data/auto-mpg.csv\n", "Dataset size: 200 99 99\n", "Data saved to /tmp/tmpnpjgki5b/output/auto-mpg/2023-09-23-20-37-47-0_UserInputConfig (data.csv and tabular_data.csv).\n", "\n", "-------------Run PytorchTabular-------------\n", "\n", "Training Category Embedding\n", "Global seed set to 42\n", "2023-09-23 20:38:02,872 - {pytorch_tabular.tabular_model:473} - INFO - Preparing the DataLoaders\n", "2023-09-23 20:38:02,874 - {pytorch_tabular.tabular_datamodule:290} - INFO - Setting up the datamodule for regression task\n", "2023-09-23 20:38:02,883 - {pytorch_tabular.tabular_model:521} - INFO - Preparing the Model: CategoryEmbeddingModel\n", "2023-09-23 20:38:02,899 - {pytorch_tabular.tabular_model:268} - INFO - Preparing the Trainer\n", "/home/xlluo/anaconda3/envs/tabular_ensemble/lib/python3.10/site-packages/pytorch_lightning/trainer/connectors/accelerator_connector.py:589: LightningDeprecationWarning: The Trainer argument `auto_select_gpus` has been deprecated in v1.9.0 and will be removed in v2.0.0. Please use the function `pytorch_lightning.accelerators.find_usable_cuda_devices` instead.\n", " rank_zero_deprecation(\n", "Auto select gpus: [0]\n", "GPU available: True (cuda), used: True\n", "TPU available: False, using: 0 TPU cores\n", "IPU available: False, using: 0 IPUs\n", "HPU available: False, using: 0 HPUs\n", "2023-09-23 20:38:02,922 - {pytorch_tabular.tabular_model:582} - INFO - Training Started\n", "You are using a CUDA device ('NVIDIA GeForce RTX 3090') that has Tensor Cores. To properly utilize them, you should set `torch.set_float32_matmul_precision('medium' | 'high')` which will trade-off precision for performance. For more details, read https://pytorch.org/docs/stable/generated/torch.set_float32_matmul_precision.html#torch.set_float32_matmul_precision\n", "LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]\n", "\n", " | Name | Type | Params\n", "---------------------------------------------------------------\n", "0 | _backbone | CategoryEmbeddingBackbone | 11.4 K\n", "1 | _embedding_layer | Embedding1dLayer | 14 \n", "2 | head | LinearHead | 33 \n", "3 | loss | MSELoss | 0 \n", "---------------------------------------------------------------\n", "11.4 K Trainable params\n", "0 Non-trainable params\n", "11.4 K Total params\n", "0.046 Total estimated model params size (MB)\n", "Epoch: 1/300, Train loss: 645.7930, Val loss: 634.2722, Min val loss: 634.2722, Epoch time: 0.017s.\n", "Epoch: 20/300, Train loss: 326.0877, Val loss: 323.5532, Min val loss: 323.5532, Epoch time: 0.012s.\n", "Epoch: 40/300, Train loss: 79.7064, Val loss: 70.4397, Min val loss: 70.4397, Epoch time: 0.011s.\n", "Epoch: 60/300, Train loss: 46.4769, Val loss: 33.4822, Min val loss: 33.4822, Epoch time: 0.011s.\n", "Epoch: 80/300, Train loss: 33.4557, Val loss: 23.5222, Min val loss: 23.5222, Epoch time: 0.011s.\n", "Epoch: 100/300, Train loss: 27.6559, Val loss: 19.9502, Min val loss: 19.9502, Epoch time: 0.011s.\n", "Epoch: 120/300, Train loss: 20.6489, Val loss: 17.9041, Min val loss: 17.9041, Epoch time: 0.013s.\n", "Epoch: 140/300, Train loss: 19.6383, Val loss: 17.4171, Min val loss: 17.4171, Epoch time: 0.010s.\n", "Epoch: 160/300, Train loss: 16.6578, Val loss: 16.3154, Min val loss: 16.2164, Epoch time: 0.011s.\n", "Epoch: 180/300, Train loss: 19.6480, Val loss: 15.2104, Min val loss: 15.2104, Epoch time: 0.010s.\n", "Epoch: 200/300, Train loss: 15.6033, Val loss: 14.5753, Min val loss: 14.5753, Epoch time: 0.011s.\n", "Epoch: 220/300, Train loss: 13.8016, Val loss: 13.8601, Min val loss: 13.8468, Epoch time: 0.009s.\n", "Epoch: 240/300, Train loss: 15.3606, Val loss: 12.9441, Min val loss: 12.9441, Epoch time: 0.011s.\n", "Epoch: 260/300, Train loss: 14.5253, Val loss: 12.5276, Min val loss: 12.5276, Epoch time: 0.011s.\n", "Epoch: 280/300, Train loss: 15.3802, Val loss: 12.0176, Min val loss: 12.0176, Epoch time: 0.009s.\n", "Epoch: 300/300, Train loss: 14.3208, Val loss: 11.5972, Min val loss: 11.5972, Epoch time: 0.010s.\n", "`Trainer.fit` stopped: `max_epochs=300` reached.\n", "2023-09-23 20:38:07,954 - {pytorch_tabular.tabular_model:584} - INFO - Training the model completed\n", "2023-09-23 20:38:07,954 - {pytorch_tabular.tabular_model:1258} - INFO - Loading the best model\n", "/home/xlluo/anaconda3/envs/tabular_ensemble/lib/python3.10/site-packages/pytorch_lightning/utilities/cloud_io.py:33: LightningDeprecationWarning: `pytorch_lightning.utilities.cloud_io.get_filesystem` has been deprecated in v1.8.0 and will be removed in v2.0.0. Please use `lightning_fabric.utilities.cloud_io.get_filesystem` instead.\n", " rank_zero_deprecation(\n", "Training mse loss: 8.63738\n", "Validation mse loss: 11.59718\n", "Testing mse loss: 16.02349\n", "Trainer saved. To load the trainer, run trainer = load_trainer(path='/tmp/tmpnpjgki5b/output/auto-mpg/2023-09-23-20-37-47-0_UserInputConfig/trainer.pkl')\n", "\n", "-------------PytorchTabular End-------------\n", "\n", "Category Embedding 1/1\n", "--------------------------End 3/4 cv--------------------------\n", "----------------------------4/4 cv----------------------------\n", "Using previously used data path /tmp/tmpnpjgki5b/data/auto-mpg.csv\n", "Dataset size: 200 99 99\n", "Data saved to /tmp/tmpnpjgki5b/output/auto-mpg/2023-09-23-20-37-47-0_UserInputConfig (data.csv and tabular_data.csv).\n", "\n", "-------------Run PytorchTabular-------------\n", "\n", "Training Category Embedding\n", "Global seed set to 42\n", "2023-09-23 20:38:08,438 - {pytorch_tabular.tabular_model:473} - INFO - Preparing the DataLoaders\n", "2023-09-23 20:38:08,439 - {pytorch_tabular.tabular_datamodule:290} - INFO - Setting up the datamodule for regression task\n", "2023-09-23 20:38:08,447 - {pytorch_tabular.tabular_model:521} - INFO - Preparing the Model: CategoryEmbeddingModel\n", "2023-09-23 20:38:08,458 - {pytorch_tabular.tabular_model:268} - INFO - Preparing the Trainer\n", "/home/xlluo/anaconda3/envs/tabular_ensemble/lib/python3.10/site-packages/pytorch_lightning/trainer/connectors/accelerator_connector.py:589: LightningDeprecationWarning: The Trainer argument `auto_select_gpus` has been deprecated in v1.9.0 and will be removed in v2.0.0. Please use the function `pytorch_lightning.accelerators.find_usable_cuda_devices` instead.\n", " rank_zero_deprecation(\n", "Auto select gpus: [0]\n", "GPU available: True (cuda), used: True\n", "TPU available: False, using: 0 TPU cores\n", "IPU available: False, using: 0 IPUs\n", "HPU available: False, using: 0 HPUs\n", "2023-09-23 20:38:08,473 - {pytorch_tabular.tabular_model:582} - INFO - Training Started\n", "You are using a CUDA device ('NVIDIA GeForce RTX 3090') that has Tensor Cores. To properly utilize them, you should set `torch.set_float32_matmul_precision('medium' | 'high')` which will trade-off precision for performance. For more details, read https://pytorch.org/docs/stable/generated/torch.set_float32_matmul_precision.html#torch.set_float32_matmul_precision\n", "LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]\n", "\n", " | Name | Type | Params\n", "---------------------------------------------------------------\n", "0 | _backbone | CategoryEmbeddingBackbone | 11.4 K\n", "1 | _embedding_layer | Embedding1dLayer | 14 \n", "2 | head | LinearHead | 33 \n", "3 | loss | MSELoss | 0 \n", "---------------------------------------------------------------\n", "11.4 K Trainable params\n", "0 Non-trainable params\n", "11.4 K Total params\n", "0.046 Total estimated model params size (MB)\n", "Epoch: 1/300, Train loss: 636.0693, Val loss: 673.2845, Min val loss: 673.2845, Epoch time: 0.011s.\n", "Epoch: 20/300, Train loss: 320.2209, Val loss: 352.5726, Min val loss: 352.5726, Epoch time: 0.009s.\n", "Epoch: 40/300, Train loss: 72.3203, Val loss: 74.2078, Min val loss: 74.2078, Epoch time: 0.010s.\n", "Epoch: 60/300, Train loss: 41.2314, Val loss: 47.7063, Min val loss: 47.7063, Epoch time: 0.008s.\n", "Epoch: 80/300, Train loss: 31.4739, Val loss: 34.3773, Min val loss: 34.3773, Epoch time: 0.009s.\n", "Epoch: 100/300, Train loss: 26.7886, Val loss: 28.7385, Min val loss: 28.7385, Epoch time: 0.008s.\n", "Epoch: 120/300, Train loss: 20.0182, Val loss: 24.3363, Min val loss: 24.3363, Epoch time: 0.009s.\n", "Epoch: 140/300, Train loss: 19.3822, Val loss: 22.6521, Min val loss: 22.6521, Epoch time: 0.012s.\n", "Epoch: 160/300, Train loss: 19.0349, Val loss: 21.4546, Min val loss: 21.4546, Epoch time: 0.009s.\n", "Epoch: 180/300, Train loss: 16.7342, Val loss: 19.9216, Min val loss: 19.9216, Epoch time: 0.009s.\n", "Epoch: 200/300, Train loss: 14.9367, Val loss: 18.7599, Min val loss: 18.7599, Epoch time: 0.009s.\n", "Epoch: 220/300, Train loss: 15.6413, Val loss: 18.2248, Min val loss: 18.2248, Epoch time: 0.010s.\n", "Epoch: 240/300, Train loss: 16.4146, Val loss: 17.3294, Min val loss: 17.3294, Epoch time: 0.009s.\n", "Epoch: 260/300, Train loss: 13.5992, Val loss: 16.4097, Min val loss: 16.4097, Epoch time: 0.013s.\n", "Epoch: 280/300, Train loss: 12.5998, Val loss: 15.9688, Min val loss: 15.5961, Epoch time: 0.009s.\n", "Epoch: 300/300, Train loss: 15.1886, Val loss: 14.6322, Min val loss: 14.6322, Epoch time: 0.011s.\n", "`Trainer.fit` stopped: `max_epochs=300` reached.\n", "2023-09-23 20:38:12,907 - {pytorch_tabular.tabular_model:584} - INFO - Training the model completed\n", "2023-09-23 20:38:12,908 - {pytorch_tabular.tabular_model:1258} - INFO - Loading the best model\n", "/home/xlluo/anaconda3/envs/tabular_ensemble/lib/python3.10/site-packages/pytorch_lightning/utilities/cloud_io.py:33: LightningDeprecationWarning: `pytorch_lightning.utilities.cloud_io.get_filesystem` has been deprecated in v1.8.0 and will be removed in v2.0.0. Please use `lightning_fabric.utilities.cloud_io.get_filesystem` instead.\n", " rank_zero_deprecation(\n", "Training mse loss: 8.95723\n", "Validation mse loss: 14.63222\n", "Testing mse loss: 12.50395\n", "Trainer saved. To load the trainer, run trainer = load_trainer(path='/tmp/tmpnpjgki5b/output/auto-mpg/2023-09-23-20-37-47-0_UserInputConfig/trainer.pkl')\n", "\n", "-------------PytorchTabular End-------------\n", "\n", "Category Embedding 1/1\n", "--------------------------End 4/4 cv--------------------------\n", "Trainer saved. To load the trainer, run trainer = load_trainer(path='/tmp/tmpnpjgki5b/output/auto-mpg/2023-09-23-20-37-47-0_UserInputConfig/trainer.pkl')\n" ] }, { "data": { "text/plain": " Program Model Training RMSE Training MSE \\\n0 PytorchTabular Category Embedding 3.121511 9.743828 \n\n Training MAE Training MAPE Training R2 Training MEDIAN_ABSOLUTE_ERROR \\\n0 2.361333 0.100122 0.839443 1.824559 \n\n Training EXPLAINED_VARIANCE_SCORE Testing RMSE ... Testing R2 \\\n0 0.870805 3.610387 ... 0.786089 \n\n Testing MEDIAN_ABSOLUTE_ERROR Testing EXPLAINED_VARIANCE_SCORE \\\n0 2.024105 0.814192 \n\n Validation RMSE Validation MSE Validation MAE Validation MAPE \\\n0 3.82657 14.642641 2.699677 0.119046 \n\n Validation R2 Validation MEDIAN_ABSOLUTE_ERROR \\\n0 0.761043 1.905207 \n\n Validation EXPLAINED_VARIANCE_SCORE \n0 0.785311 \n\n[1 rows x 23 columns]", "text/html": "
| \n | Program | \nModel | \nTraining RMSE | \nTraining MSE | \nTraining MAE | \nTraining MAPE | \nTraining R2 | \nTraining MEDIAN_ABSOLUTE_ERROR | \nTraining EXPLAINED_VARIANCE_SCORE | \nTesting RMSE | \n... | \nTesting R2 | \nTesting MEDIAN_ABSOLUTE_ERROR | \nTesting EXPLAINED_VARIANCE_SCORE | \nValidation RMSE | \nValidation MSE | \nValidation MAE | \nValidation MAPE | \nValidation R2 | \nValidation MEDIAN_ABSOLUTE_ERROR | \nValidation EXPLAINED_VARIANCE_SCORE | \n
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \nPytorchTabular | \nCategory Embedding | \n3.121511 | \n9.743828 | \n2.361333 | \n0.100122 | \n0.839443 | \n1.824559 | \n0.870805 | \n3.610387 | \n... | \n0.786089 | \n2.024105 | \n0.814192 | \n3.82657 | \n14.642641 | \n2.699677 | \n0.119046 | \n0.761043 | \n1.905207 | \n0.785311 | \n
1 rows × 23 columns
\n| \n | Program | \nModel | \nTraining RMSE | \nTraining MSE | \nTraining MAE | \nTraining MAPE | \nTraining R2 | \nTraining MEDIAN_ABSOLUTE_ERROR | \nTraining EXPLAINED_VARIANCE_SCORE | \nTesting RMSE | \n... | \nTesting R2 | \nTesting MEDIAN_ABSOLUTE_ERROR | \nTesting EXPLAINED_VARIANCE_SCORE | \nValidation RMSE | \nValidation MSE | \nValidation MAE | \nValidation MAPE | \nValidation R2 | \nValidation MEDIAN_ABSOLUTE_ERROR | \nValidation EXPLAINED_VARIANCE_SCORE | \n
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \nPytorchTabular | \nCategory Embedding | \n3.195748 | \n10.212808 | \n2.387656 | \n0.101595 | \n0.838209 | \n1.844076 | \n0.865946 | \n3.199201 | \n... | \n0.822679 | \n2.022343 | \n0.856969 | \n3.620434 | \n13.107543 | \n2.541972 | \n0.11167 | \n0.771539 | \n1.739592 | \n0.783368 | \n
1 rows × 23 columns
\n| \n | Program | \nModel | \nTraining RMSE | \nTraining MSE | \nTraining MAE | \nTraining MAPE | \nTraining R2 | \nTraining MEDIAN_ABSOLUTE_ERROR | \nTraining EXPLAINED_VARIANCE_SCORE | \nTesting RMSE | \n... | \nTesting R2 | \nTesting MEDIAN_ABSOLUTE_ERROR | \nTesting EXPLAINED_VARIANCE_SCORE | \nValidation RMSE | \nValidation MSE | \nValidation MAE | \nValidation MAPE | \nValidation R2 | \nValidation MEDIAN_ABSOLUTE_ERROR | \nValidation EXPLAINED_VARIANCE_SCORE | \n
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \nPytorchTabular | \nCategory Embedding | \n3.273904 | \n10.718448 | \n2.439552 | \n0.103957 | \n0.827288 | \n1.87891 | \n0.857783 | \n2.980939 | \n... | \n0.844204 | \n1.972121 | \n0.890054 | \n3.950363 | \n15.605369 | \n2.875634 | \n0.123573 | \n0.745909 | \n2.082971 | \n0.763982 | \n
1 rows × 23 columns
\n| \n | Program | \nModel | \nTraining RMSE | \nTraining MSE | \nTraining MAE | \nTraining MAPE | \nTraining R2 | \nTraining MEDIAN_ABSOLUTE_ERROR | \nTraining EXPLAINED_VARIANCE_SCORE | \nTesting RMSE | \n... | \nTesting R2 | \nTesting MEDIAN_ABSOLUTE_ERROR | \nTesting EXPLAINED_VARIANCE_SCORE | \nValidation RMSE | \nValidation MSE | \nValidation MAE | \nValidation MAPE | \nValidation R2 | \nValidation MEDIAN_ABSOLUTE_ERROR | \nValidation EXPLAINED_VARIANCE_SCORE | \n
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \nPytorchTabular | \nCategory Embedding | \n3.273904 | \n10.718448 | \n2.439552 | \n0.103957 | \n0.827288 | \n1.87891 | \n0.857783 | \n2.980939 | \n... | \n0.844204 | \n1.972121 | \n0.890054 | \n3.950363 | \n15.605369 | \n2.875634 | \n0.123573 | \n0.745909 | \n2.082971 | \n0.763982 | \n
1 rows × 23 columns
\n