{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":81933,"databundleVersionId":9643020,"sourceType":"competition"}],"dockerImageVersionId":30775,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"<div style=\"\n  display: flex;\n  flex-wrap: wrap; \n  justify-content: center; \n  align-items: center;\n  padding: 20px;\n\">\n\n  <!-- Neomorphic Image Container -->\n  <div style=\"\n    background: #e0e0e0;\n    border-radius: 20px;\n    box-shadow: 8px 8px 15px #aaa, -8px -8px 15px #fff;\n    padding: 20px;\n    margin: 10px;\n    flex: 1 1 400px; /* Ensures both containers take up equal space */\n    max-width: 500px; /* Controls max width for responsiveness */\n    display: flex;\n    justify-content: center;\n    align-items: center;\n  \">\n    <img src=\"https://storage.googleapis.com/kaggle-organizations/3842/thumbnail.jpg\" alt=\"Heart Attack Image\" style=\"\n      border-radius: 10px;\n      display: block;\n      max-width: 100%;\n      height: auto;\n    \">\n  </div>\n\n  <!-- Neomorphic Text Container -->\n  <div style=\"\n    background: #e0e0e0;\n    border-radius: 20px;\n    box-shadow: 8px 8px 15px #aaa, -8px -8px 15px #fff;\n    padding: 20px;\n    margin: 10px;\n    flex: 1 1 400px; /* Ensures both containers take up equal space */\n    max-width: 500px; /* Controls max width for responsiveness */\n    display: flex;\n    justify-content: center;\n    align-items: center;\n  \">\n    <h1 style=\"\n      font-family: 'Arial', sans-serif; \n      font-size: 3em; \n      color: #b0b0b0; \n      text-shadow: \n        4px 4px 8px rgba(0,0,0,0.3), \n        -4px -4px 8px rgba(255,255,255,0.5),\n        1px 1px 3px rgba(0,0,0,0.2);\n      text-align: center;\n      line-height: 1.2em;\n      margin: 0;\n    \">\n      <br>PROBLEMATIC<br><br>INTERNET USE\n    </h1>\n  </div>\n","metadata":{}},{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# 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\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = pd.read_csv(\"/kaggle/input/child-mind-institute-problematic-internet-use/train.csv\")","metadata":{"execution":{"iopub.status.busy":"2024-09-27T05:31:34.169252Z","iopub.execute_input":"2024-09-27T05:31:34.169680Z","iopub.status.idle":"2024-09-27T05:31:34.225013Z","shell.execute_reply.started":"2024-09-27T05:31:34.169635Z","shell.execute_reply":"2024-09-27T05:31:34.223487Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style=\"margin: 20px; border-radius: 15px; background-color: #e0e0e0; padding: 20px; box-shadow: 8px 8px 15px #bebebe, -8px -8px 15px #ffffff;\">\n    <h1 style=\"font-family: 'Arial', sans-serif; font-size: 2.5em; color: #b0b0b0; \n               text-shadow: \n               4px 4px 8px rgba(0,0,0,0.3), \n               -4px -4px 8px rgba(255,255,255,0.5),\n               1px 1px 3px rgba(0,0,0,0.2);\n               text-align: center;\">\n        EXPLORE HEART DATASET \n    </h1>\n</div>\n","metadata":{}},{"cell_type":"markdown","source":"<div style=\"margin: 20px; border-radius: 15px; background-color: #e0e0e0; padding: 20px; box-shadow: 8px 8px 15px #bebebe, -8px -8px 15px #ffffff; text-align: center; font-weight: bold;\">\n     How big is the data?\n</div>","metadata":{}},{"cell_type":"code","source":"data.shape","metadata":{"execution":{"iopub.status.busy":"2024-09-27T05:32:40.126003Z","iopub.execute_input":"2024-09-27T05:32:40.127354Z","iopub.status.idle":"2024-09-27T05:32:40.136124Z","shell.execute_reply.started":"2024-09-27T05:32:40.127303Z","shell.execute_reply":"2024-09-27T05:32:40.134800Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style=\"margin: 20px; border-radius: 15px; background-color: #e0e0e0; padding: 20px; box-shadow: 8px 8px 15px #bebebe, -8px -8px 15px #ffffff; text-align: center; font-weight: bold;\">\n     How does the data look like?\n</div>","metadata":{}},{"cell_type":"code","source":"from IPython.core.display import HTML\n\n# Convert DataFrame to HTML\nhtml_table = data.head(5).to_html(classes='neomorphism-table', index=False)\n\n# Embed HTML and CSS into the notebook\ncontent = f\"\"\"\n<style>\n.neomorphism-container {{\n    background: #e0e0e0;\n    border-radius: 15px;\n    box-shadow:  8px 8px 16px #bebebe, \n                 -8px -8px 16px #ffffff;\n    padding: 20px;\n    width: 100%;\n    max-width: 800px;\n    margin: 20px auto;\n}}\n\n.neomorphism-table {{\n    width: 90%;\n    border-collapse: collapse;\n}}\n\n.neomorphism-table thead {{\n    background-color: #f4f4f4;\n}}\n\n.neomorphism-table th, .neomorphism-table td {{\n    padding: 10px;\n    text-align: left;\n    border-bottom: 1px solid #ddd;\n}}\n\n.neomorphism-table th {{\n    background-color: #f0f0f0;\n}}\n\n.neomorphism-table tr:hover {{\n    background-color: #f9f9f9;\n}}\n</style>\n\n<div class=\"neomorphism-container\">\n{html_table}\n</div>\n\"\"\"\n\n# Display the HTML content\ndisplay(HTML(content))","metadata":{"execution":{"iopub.status.busy":"2024-09-27T05:33:43.149611Z","iopub.execute_input":"2024-09-27T05:33:43.150865Z","iopub.status.idle":"2024-09-27T05:33:43.215558Z","shell.execute_reply.started":"2024-09-27T05:33:43.150808Z","shell.execute_reply":"2024-09-27T05:33:43.214042Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style=\"margin: 20px; border-radius: 15px; background-color: #e0e0e0; padding: 20px; box-shadow: 8px 8px 15px #bebebe, -8px -8px 15px #ffffff; text-align: center; font-weight: bold;\">\n     What is the data-type of columns?\n</div>","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nfrom IPython.core.display import HTML\n\n# Create a DataFrame with information\ninfo_dict = {\n    'Column Name': data.columns,\n    'Non-Null Count': [f'{data[col].notnull().sum()} non-null' for col in data.columns],\n    'Dtype': [data[col].dtype for col in data.columns]\n}\n\ninfo_df = pd.DataFrame(info_dict)\n\n# Convert DataFrame to HTML\nhtml_table = info_df.to_html(classes='neomorphism-table', index=False)\n\n# Define the HTML and CSS for styling\ninfo_content = f\"\"\"\n<style>\n.neomorphism-container {{\n    background: #e0e0e0;\n    border-radius: 15px;\n    box-shadow:  8px 8px 16px #bebebe, \n                 -8px -8px 16px #ffffff;\n    padding: 20px;\n    width: 90%;\n    max-width: 800px;\n    margin: 20px auto;\n}}\n\n.neomorphism-table {{\n    width: 100%;\n    border-collapse: collapse;\n}}\n\n.neomorphism-table thead {{\n    background-color: #f4f4f4;\n}}\n\n.neomorphism-table th, .neomorphism-table td {{\n    padding: 10px;\n    text-align: left;\n    border-bottom: 1px solid #ddd;\n}}\n\n.neomorphism-table th {{\n    background-color: #f0f0f0;\n}}\n\n.neomorphism-table tr:hover {{\n    background-color: #f9f9f9;\n}}\n</style>\n\n<div class=\"neomorphism-container\">\n{html_table}\n</div>\n\"\"\"\n\n# Display the HTML content\ndisplay(HTML(info_content))\n","metadata":{"execution":{"iopub.status.busy":"2024-09-27T05:35:34.427340Z","iopub.execute_input":"2024-09-27T05:35:34.427801Z","iopub.status.idle":"2024-09-27T05:35:34.484697Z","shell.execute_reply.started":"2024-09-27T05:35:34.427747Z","shell.execute_reply":"2024-09-27T05:35:34.482910Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style=\"margin: 20px; border-radius: 15px; background-color: #e0e0e0; padding: 20px; box-shadow: 8px 8px 15px #bebebe, -8px -8px 15px #ffffff; text-align: center; font-weight: bold;\">\n     Are there any missing values?\n</div>","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nfrom IPython.core.display import HTML\n\n# Calculate the number of missing values for each column\nmissing_values = data.isnull().sum()\n\n# Convert the missing values Series to DataFrame for better presentation\nmissing_values_df = pd.DataFrame({\n    'Column Name': missing_values.index,\n    'Missing Values': missing_values.values\n})\n\n# Convert the missing values DataFrame to HTML\nhtml_table = missing_values_df.to_html(classes='neomorphism-table', index=False)\n\n# Define the HTML and CSS for styling\nmissing_content = f\"\"\"\n<style>\n.neomorphism-container {{\n    background: #e0e0e0;\n    border-radius: 15px;\n    box-shadow:  8px 8px 16px #bebebe, \n                 -8px -8px 16px #ffffff;\n    padding: 20px;\n    width: 90%;\n    max-width: 800px;\n    margin: 20px auto;\n}}\n\n.neomorphism-table {{\n    width: 100%;\n    border-collapse: collapse;\n}}\n\n.neomorphism-table thead {{\n    background-color: #f4f4f4;\n}}\n\n.neomorphism-table th, .neomorphism-table td {{\n    padding: 10px;\n    text-align: left;\n    border-bottom: 1px solid #ddd;\n}}\n\n.neomorphism-table th {{\n    background-color: #f0f0f0;\n}}\n\n.neomorphism-table tr:hover {{\n    background-color: #f9f9f9;\n}}\n</style>\n\n<div class=\"neomorphism-container\">\n{html_table}\n</div>\n\"\"\"\n\n# Display the HTML content\ndisplay(HTML(missing_content))\n","metadata":{"execution":{"iopub.status.busy":"2024-09-27T05:36:43.264332Z","iopub.execute_input":"2024-09-27T05:36:43.264914Z","iopub.status.idle":"2024-09-27T05:36:43.291600Z","shell.execute_reply.started":"2024-09-27T05:36:43.264855Z","shell.execute_reply":"2024-09-27T05:36:43.290321Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style=\"margin: 20px; border-radius: 15px; background-color: #e0e0e0; padding: 20px; box-shadow: 8px 8px 15px #bebebe, -8px -8px 15px #ffffff; text-align: center; font-weight: bold;\">\n      How does the data look like mathematically?\n</div>","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nfrom IPython.core.display import HTML\n\n# Generate summary statistics\nsummary_stats = data.describe()\n\n# Convert summary statistics DataFrame to HTML\nhtml_table = summary_stats.to_html(classes='neomorphism-table')\n\n# Define the HTML and CSS for styling\ndescribe_content = f\"\"\"\n<style>\n.neomorphism-container {{\n    background: #e0e0e0;\n    border-radius: 15px;\n    box-shadow:  8px 8px 16px #bebebe, \n                 -8px -8px 16px #ffffff;\n    padding: 20px;\n    width: 95%;\n    max-width: 1300px;\n    margin: 20px auto;\n}}\n\n.neomorphism-table {{\n    width: 100%;\n    border-collapse: collapse;\n}}\n\n.neomorphism-table thead {{\n    background-color: #f4f4f4;\n}}\n\n.neomorphism-table th, .neomorphism-table td {{\n    padding: 10px;\n    text-align: left;\n    border-bottom: 1px solid #ddd;\n}}\n\n.neomorphism-table th {{\n    background-color: #f0f0f0;\n}}\n\n.neomorphism-table tr:hover {{\n    background-color: #f9f9f9;\n}}\n</style>\n\n<div class=\"neomorphism-container\">\n{html_table}\n</div>\n\"\"\"\n\n# Display the HTML content\ndisplay(HTML(describe_content))","metadata":{"execution":{"iopub.status.busy":"2024-09-27T05:38:30.100109Z","iopub.execute_input":"2024-09-27T05:38:30.100615Z","iopub.status.idle":"2024-09-27T05:38:30.314965Z","shell.execute_reply.started":"2024-09-27T05:38:30.100569Z","shell.execute_reply":"2024-09-27T05:38:30.313568Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style=\"margin: 20px; border-radius: 15px; background-color: #e0e0e0; padding: 20px; box-shadow: 8px 8px 15px #bebebe, -8px -8px 15px #ffffff; text-align: center; font-weight: bold;\">\n     Are there duplicate values?\n</div>","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nfrom IPython.core.display import HTML\n\n# Calculate the number of duplicate rows\nduplicate_counts = data.duplicated().sum()\n\n# Prepare information about duplicates\nduplicate_info = pd.DataFrame({\n    'Duplicate Rows': [duplicate_counts]\n})\n\n# Convert the duplicate info DataFrame to HTML\nhtml_table = duplicate_info.to_html(classes='neomorphism-table', index=False)\n\n# Define the HTML and CSS for styling\nduplicate_content = f\"\"\"\n<style>\n.neomorphism-container {{\n    background: #e0e0e0;\n    border-radius: 15px;\n    box-shadow:  8px 8px 16px #bebebe, \n                 -8px -8px 16px #ffffff;\n    padding: 20px;\n    width: 90%;\n    max-width: 800px;\n    margin: 20px auto;\n    font-family: Arial, sans-serif;\n}}\n\n.neomorphism-table {{\n    width: 100%;\n    border-collapse: collapse;\n}}\n\n.neomorphism-table thead {{\n    background-color: #f4f4f4;\n}}\n\n.neomorphism-table th, .neomorphism-table td {{\n    padding: 10px;\n    text-align: left;\n    border-bottom: 1px solid #ddd;\n}}\n\n.neomorphism-table th {{\n    background-color: #f0f0f0;\n}}\n\n.neomorphism-table tr:hover {{\n    background-color: #f9f9f9;\n}}\n</style>\n\n<div class=\"neomorphism-container\">\n<h3>Duplicate Rows Information</h3>\n{html_table}\n</div>\n\"\"\"\n\n# Display the HTML content\ndisplay(HTML(duplicate_content))","metadata":{"execution":{"iopub.status.busy":"2024-09-27T05:39:13.847570Z","iopub.execute_input":"2024-09-27T05:39:13.848067Z","iopub.status.idle":"2024-09-27T05:39:13.892667Z","shell.execute_reply.started":"2024-09-27T05:39:13.848023Z","shell.execute_reply":"2024-09-27T05:39:13.890583Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style=\"margin: 20px; border-radius: 15px; background-color: #e0e0e0; padding: 20px; box-shadow: 8px 8px 15px #bebebe, -8px -8px 15px #ffffff; text-align: center; font-weight: bold;\">\n     How is the correlation between the columns?\n</div>","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nfrom IPython.core.display import HTML\n\n# Calculate the correlation matrix\nnew_col = data.select_dtypes(include=[\"int\",\"float\"])\ncorrelation_matrix = new_col.corr()\n\n# Convert the correlation matrix DataFrame to HTML\nhtml_table = correlation_matrix.to_html(classes='neomorphism-table')\n\n# Define the HTML and CSS for styling\ncorr_content = f\"\"\"\n<style>\n.neomorphism-container {{\n    background: #e0e0e0;\n    border-radius: 15px;\n    box-shadow:  8px 8px 16px #bebebe, \n                 -8px -8px 16px #ffffff;\n    padding: 20px;\n    width: 90%;\n    max-width: 1600px;\n    margin: 20px auto;\n    font-family: Arial, sans-serif;\n}}\n\n.neomorphism-table {{\n    width: 100%;\n    border-collapse: collapse;\n}}\n\n.neomorphism-table thead {{\n    background-color: #f4f4f4;\n}}\n\n.neomorphism-table th, .neomorphism-table td {{\n    padding: 10px;\n    text-align: left;\n    border-bottom: 1px solid #ddd;\n}}\n\n.neomorphism-table th {{\n    background-color: #f0f0f0;\n}}\n\n.neomorphism-table tr:hover {{\n    background-color: #f9f9f9;\n}}\n</style>\n\n<div class=\"neomorphism-container\">\n<h3>Correlation Matrix</h3>\n{html_table}\n</div>\n\"\"\"\n\n# Display the HTML content\ndisplay(HTML(corr_content))\n","metadata":{"execution":{"iopub.status.busy":"2024-09-27T05:42:09.624861Z","iopub.execute_input":"2024-09-27T05:42:09.626357Z","iopub.status.idle":"2024-09-27T05:42:09.854257Z","shell.execute_reply.started":"2024-09-27T05:42:09.626281Z","shell.execute_reply":"2024-09-27T05:42:09.852962Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style=\"margin: 20px; border-radius: 15px; background-color: #e0e0e0; padding: 20px; box-shadow: 8px 8px 15px #bebebe, -8px -8px 15px #ffffff; text-align: center; font-weight: bold;\">\n     Visualizing Correlation Matrix\n</div>","metadata":{}},{"cell_type":"code","source":"import plotly.express as px\nimport pandas as pd\n\n# Calculate the correlation matrix\ncorrelation_matrix = new_col.corr()\n\n# Create the heatmap using Plotly\nfig = px.imshow(\n    correlation_matrix,\n    text_auto=True,\n    color_continuous_scale='Viridis',  # You can change the color scale as needed\n    title='Correlation Matrix'\n)\n\n# Update layout for better appearance\nfig.update_layout(\n    xaxis_title='Features',\n    yaxis_title='Features',\n    xaxis={'side': 'top'},  # Place x-axis labels at the top\n    width=800,\n    height=600,\n    coloraxis_colorbar=dict(title='Correlation')\n)\n\n# Show the figure\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2024-09-27T05:43:13.976276Z","iopub.execute_input":"2024-09-27T05:43:13.977351Z","iopub.status.idle":"2024-09-27T05:43:17.014969Z","shell.execute_reply.started":"2024-09-27T05:43:13.977296Z","shell.execute_reply":"2024-09-27T05:43:17.013601Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style=\"margin: 20px; border-radius: 15px; background-color: #e0e0e0; padding: 20px; box-shadow: 8px 8px 15px #bebebe, -8px -8px 15px #ffffff; text-align: center; font-weight: bold;\">\n     <h2>Thank you for visiting my notebook. I am still working on this dataset, any progress will be updated soon...\n    </h2>\n</div>","metadata":{}},{"cell_type":"markdown","source":"","metadata":{}}]}