{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# {{ project_name }} - Kaggle Base\n",
"\n",
"**Author:** {{ author_name }}\n",
"**Description:** {{ description }}\n",
"\n",
"This notebook demonstrates data loading using **KaggleHub**."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Universal Setup (Local / Colab / Kaggle)\n",
"import sys\n",
"import os\n",
"import yaml\n",
"# Check if running on Colab\n",
"if 'google.colab' in sys.modules:\n",
" print('Detected Google Colab environment')\n",
" # Clone/Install the package if needed\n",
" # !pip install git+https://github.com/{{ author_name | lower | replace(' ', '') }}/{{ project_name }}.git\n",
"\n",
"from {{ package_name }} import get_config\n",
"\n",
"print(f\"Project: {get_config('project_name')}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Standard Imports\n",
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"import seaborn as sns\n",
"import kagglehub as kh\n",
"\n",
"{% if project_type == 'dl' %}\n",
"{% if framework == 'pytorch' %}\n",
"import torch\n",
"print(f\"PyTorch Version: {torch.__version__}\")\n",
"print(f\"CUDA Available: {torch.cuda.is_available()}\")\n",
"{% elif framework == 'tensorflow' %}\n",
"import tensorflow as tf\n",
"print(f\"TensorFlow Version: {tf.__version__}\")\n",
"print(f\"GPU Available: {len(tf.config.list_physical_devices('GPU')) > 0}\")\n",
"{% endif %}\n",
"{% endif %}\n",
"\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Load Dataset using Config + KaggleHub\n",
"try:\n",
" # Load dataset handle from config\n",
" dataset_handle = get_config('datasets', {}).get('Base_Kaggle', 'titanic')\n",
" print(f\"Loading dataset: {dataset_handle}...\")\n",
" \n",
" path = kh.dataset_download(dataset_handle)\n",
" print(f\"Path: {path}\")\n",
" \n",
" # Logic to find csv in path\n",
" import glob\n",
" csv_files = glob.glob(f\"{path}/*.csv\")\n",
" if csv_files:\n",
" df = pd.read_csv(csv_files[0])\n",
" display(df.head())\n",
" df.info()\n",
" else:\n",
" print(\"No CSV found in dataset.\")\n",
"except Exception as e:\n",
" print(f\"Failed to load dataset: {e}\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}