{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.17","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"tpu1vmV38","dataSources":[{"sourceId":101849,"databundleVersionId":12846694,"sourceType":"competition"}],"dockerImageVersionId":31042,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# In this Topic :-\n* Visualize Complete Dataset given\n* Understand Data Given\n* Summary of DATA Analysis\n* Get Information of what Data is saying\n* Guide and Understanding Data","metadata":{}},{"cell_type":"markdown","source":"![pic](https://i.ibb.co/JRhjKvJQ/Copy-of-FB-2.png)","metadata":{}},{"cell_type":"markdown","source":"# A. Goal of Competition","metadata":{}},{"cell_type":"markdown","source":"The competition tackles a critical bottleneck in exoplanet research: moving from raw data to interpretable atmospheric models. Successful solutions will directly influence how we:\n\n### 🔭 Process data from ARIEL/JWST\n### 🌌 Prioritize targets for follow-up observations\n### 🧪 Design future instruments with better noise mitigation","metadata":{}},{"cell_type":"markdown","source":"## Develop machine learning/statistical methods to:\n\n* Extract exoplanet atmospheric signals from noisy transit spectroscopy data\n\n* Separate true planetary spectra from:\n\n* Instrumental noise (telescope/system artifacts)\n\n* Stellar activity (starspots, flares)\n\n* Limb-darkening effects (non-uniform stellar brightness)\n\n* Generalize across diverse planetary systems with varying:\n\n* Stellar types (hot/cold, large/small stars)\n\n* Orbital configurations (close/far orbits, inclined paths)","metadata":{}},{"cell_type":"markdown","source":"## Real-World Applications\n### 1. Accelerating Exoplanet Science\n* Enable rapid analysis of 1,000+ exoplanets from ARIEL (launching 2029)\n\n* Identify habitability signatures: H₂O, CO₂, CH₄ in atmospheres\n\n* Detect biosignatures: Potential markers of life (e.g., O₂ + CH₄ imbalance)\n\n### 2. Supporting ESA's ARIEL Mission\n* Develop production-ready pipelines for the mission\n\n* Solve preprocessing bottlenecks for large-scale spectral analysis\n\n* Improve multi-visit observation strategies\n\n### 3. Advancing Astronomical ML\n* Create transferable methods for JWST, future telescopes\n\n* Establish benchmarks for noise-robust signal extraction\n\n* Hybrid approaches combining physics + AI (e.g., neural differential equations)\n\n### 4. Fundamental Discoveries\n* Classify atmospheric types (hydrogen-rich, water worlds, lava planets)\n\n* Study planet formation/evolution through chemistry\n\n* Address: \"Are we alone?\" by identifying Earth-like conditions","metadata":{}},{"cell_type":"markdown","source":"# B. About DataSet Given","metadata":{}},{"cell_type":"markdown","source":"This is for the NeurIPS - ARIEL Data Challenge 2025, focused on analyzing exoplanet atmospheric data from ESA's upcoming ARIEL (Atmospheric Remote-sensing Infrared Exoplanet Large-survey) mission.","metadata":{}},{"cell_type":"markdown","source":"## **train.csv**\n\n### Each row represents one exoplanet's transit observation\n\n### wl_1 to wl_283 are flux measurements across 283 wavelength channels\n\nValues represent normalized flux (stellar light intensity after atmospheric filtering)\n\nThe signal contains:\n\n* True atmospheric absorption features\n\n* Instrumental noise\n\n* Stellar variability\n\n* Limb darkening effects","metadata":{}},{"cell_type":"code","source":"import pandas as pd\n\ntrain = pd.read_csv(\"/kaggle/input/ariel-data-challenge-2025/train.csv\")\ntrain.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-27T02:56:30.738115Z","iopub.execute_input":"2025-06-27T02:56:30.738463Z","iopub.status.idle":"2025-06-27T02:56:30.865477Z","shell.execute_reply.started":"2025-06-27T02:56:30.738433Z","shell.execute_reply":"2025-06-27T02:56:30.860348Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## train_star_info.csv","metadata":{}},{"cell_type":"markdown","source":"### Contains physical parameters of the star-planet systems:","metadata":{}},{"cell_type":"markdown","source":"| Parameter | Description                      | Units               |\n|-----------|----------------------------------|---------------------|\n| Rs        | Stellar radius                   | Solar radii         |\n| Ms        | Stellar mass                     | Solar masses        |\n| Ts        | Stellar effective temperature    | Kelvin              |\n| Mp        | Planet mass                      | Jupiter masses      |\n| e         | Orbital eccentricity             | Dimensionless (0-1) |\n| P         | Orbital period                   | Days                |\n| sma       | Semi-major axis                  | AU                  |\n| i         | Orbital inclination              | Degrees             |","metadata":{}},{"cell_type":"code","source":"train = pd.read_csv(\"/kaggle/input/ariel-data-challenge-2025/train_star_info.csv\")\ntrain.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-27T02:56:30.867242Z","iopub.execute_input":"2025-06-27T02:56:30.867507Z","iopub.status.idle":"2025-06-27T02:56:30.891978Z","shell.execute_reply.started":"2025-06-27T02:56:30.867483Z","shell.execute_reply":"2025-06-27T02:56:30.887365Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# C. Visualization","metadata":{}},{"cell_type":"markdown","source":"## 0. Import","metadata":{}},{"cell_type":"code","source":"!pip install -q plotly\n!pip install -q ipywidgets\n\n\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D\nimport seaborn as sns\nimport plotly.express as px\nimport plotly.graph_objects as go\nfrom ipywidgets import interact, interactive, fixed, interact_manual\nimport ipywidgets as widgets\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.decomposition import PCA\n\n# Load the data\ntrain = pd.read_csv('/kaggle/input/ariel-data-challenge-2025/train.csv')\nstar_info = pd.read_csv('/kaggle/input/ariel-data-challenge-2025/train_star_info.csv')\n\n# Merge the datasets\nmerged_data = pd.merge(train, star_info, on='planet_id')\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-27T02:56:30.893433Z","iopub.execute_input":"2025-06-27T02:56:30.893635Z","iopub.status.idle":"2025-06-27T02:56:38.444296Z","shell.execute_reply.started":"2025-06-27T02:56:30.893615Z","shell.execute_reply":"2025-06-27T02:56:38.439378Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 1. Basic Information","metadata":{}},{"cell_type":"code","source":"\nprint(\"Train data shape:\", train.shape)\nprint(\"Star info shape:\", star_info.shape)\nprint(\"\\nFirst few rows of merged data:\")\ndisplay(merged_data.head())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-27T02:56:38.447013Z","iopub.execute_input":"2025-06-27T02:56:38.447425Z","iopub.status.idle":"2025-06-27T02:56:38.477501Z","shell.execute_reply.started":"2025-06-27T02:56:38.447374Z","shell.execute_reply":"2025-06-27T02:56:38.47329Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 2. Wavelength Distribution Visualization","metadata":{}},{"cell_type":"code","source":"\nwl_columns = [col for col in train.columns if col.startswith('wl_')]\n\nplt.figure(figsize=(15, 8))\nfor i in range(5):  # Plot first 5 planets' wavelength data\n    plt.plot(range(len(wl_columns)), train.iloc[i][wl_columns], label=f'Planet {train.iloc[i][\"planet_id\"]}')\nplt.xlabel('Wavelength Index')\nplt.ylabel('Intensity')\nplt.title('Wavelength Distribution for Different Planets')\nplt.legend()\nplt.grid(True)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-27T02:56:38.479932Z","iopub.execute_input":"2025-06-27T02:56:38.480652Z","iopub.status.idle":"2025-06-27T02:56:38.755549Z","shell.execute_reply.started":"2025-06-27T02:56:38.480613Z","shell.execute_reply":"2025-06-27T02:56:38.749255Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 3. Interactive Wavelength Explorer","metadata":{}},{"cell_type":"code","source":"\n@interact(planet_id=widgets.Dropdown(options=train['planet_id'].unique(), description='Select Planet:'))\ndef plot_wavelength(planet_id):\n    planet_data = train[train['planet_id'] == planet_id].iloc[0]\n    plt.figure(figsize=(12, 6))\n    plt.plot(range(len(wl_columns)), planet_data[wl_columns])\n    plt.xlabel('Wavelength Index')\n    plt.ylabel('Intensity')\n    plt.title(f'Wavelength Distribution for Planet {planet_id}')\n    plt.grid(True)\n    plt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-27T02:56:38.758452Z","iopub.execute_input":"2025-06-27T02:56:38.758835Z","iopub.status.idle":"2025-06-27T02:56:38.955635Z","shell.execute_reply.started":"2025-06-27T02:56:38.758805Z","shell.execute_reply":"2025-06-27T02:56:38.950229Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 4. Star-Planet Characteristics","metadata":{}},{"cell_type":"code","source":"\nfig, axes = plt.subplots(2, 3, figsize=(18, 12))\nsns.scatterplot(data=merged_data, x='Rs', y='Ms', ax=axes[0, 0])\nsns.scatterplot(data=merged_data, x='Ts', y='Rs', ax=axes[0, 1])\nsns.scatterplot(data=merged_data, x='Ts', y='Ms', ax=axes[0, 2])\nsns.scatterplot(data=merged_data, x='P', y='sma', ax=axes[1, 0])\nsns.scatterplot(data=merged_data, x='Mp', y='sma', ax=axes[1, 1])\nsns.scatterplot(data=merged_data, x='Mp', y='P', ax=axes[1, 2])\nplt.tight_layout()\nplt.suptitle('Star and Planet Characteristics Relationships', y=1.02)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-27T02:56:38.957568Z","iopub.execute_input":"2025-06-27T02:56:38.957794Z","iopub.status.idle":"2025-06-27T02:56:39.811887Z","shell.execute_reply.started":"2025-06-27T02:56:38.957773Z","shell.execute_reply":"2025-06-27T02:56:39.806961Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 5. 3D Visualization of Star-Planet Systems","metadata":{}},{"cell_type":"code","source":"fig = plt.figure(figsize=(12, 10))\nax = fig.add_subplot(111, projection='3d')\n\n# Normalize values for better visualization\nscaler = StandardScaler()\nscaled_data = scaler.fit_transform(merged_data[['Rs', 'Ms', 'Ts', 'Mp', 'P', 'sma']])\n\nax.scatter(scaled_data[:, 0], scaled_data[:, 1], scaled_data[:, 2], \n           c=merged_data['Ts'], cmap='viridis', s=merged_data['Mp']*50)\n\nax.set_xlabel('Star Radius (Rs)')\nax.set_ylabel('Star Mass (Ms)')\nax.set_zlabel('Star Temperature (Ts)')\nax.set_title('3D Visualization of Star-Planet Systems\\n(Color: Temperature, Size: Planet Mass)')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-27T02:56:39.813546Z","iopub.execute_input":"2025-06-27T02:56:39.813771Z","iopub.status.idle":"2025-06-27T02:56:40.095947Z","shell.execute_reply.started":"2025-06-27T02:56:39.813749Z","shell.execute_reply":"2025-06-27T02:56:40.090417Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 6. Interactive 3D Plot with Plotly","metadata":{}},{"cell_type":"code","source":"\nfig = px.scatter_3d(merged_data, x='Rs', y='Ms', z='Ts',\n                    color='Mp', size='P',\n                    hover_name='planet_id',\n                    title='Interactive 3D Visualization of Star-Planet Systems')\nfig.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-27T02:56:40.096653Z","iopub.execute_input":"2025-06-27T02:56:40.096878Z","iopub.status.idle":"2025-06-27T02:56:40.208109Z","shell.execute_reply.started":"2025-06-27T02:56:40.096857Z","shell.execute_reply":"2025-06-27T02:56:40.203606Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 7. PCA Analysis of Wavelength Data","metadata":{}},{"cell_type":"code","source":"\npca = PCA(n_components=3)\nwl_data = train[wl_columns]\npca_result = pca.fit_transform(wl_data)\n\nplt.figure(figsize=(15, 6))\nplt.subplot(1, 2, 1)\nplt.scatter(pca_result[:, 0], pca_result[:, 1], c=merged_data['Ts'], cmap='viridis')\nplt.xlabel('Principal Component 1')\nplt.ylabel('Principal Component 2')\nplt.colorbar(label='Star Temperature (Ts)')\nplt.title('PCA of Wavelength Data (PC1 vs PC2)')\n\nplt.subplot(1, 2, 2)\nplt.scatter(pca_result[:, 0], pca_result[:, 2], c=merged_data['Mp'], cmap='plasma')\nplt.xlabel('Principal Component 1')\nplt.ylabel('Principal Component 3')\nplt.colorbar(label='Planet Mass (Mp)')\nplt.title('PCA of Wavelength Data (PC1 vs PC3)')\nplt.tight_layout()\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-27T02:56:40.211214Z","iopub.execute_input":"2025-06-27T02:56:40.211488Z","iopub.status.idle":"2025-06-27T02:56:40.804852Z","shell.execute_reply.started":"2025-06-27T02:56:40.211464Z","shell.execute_reply":"2025-06-27T02:56:40.801555Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 8. Correlation Heatmap","metadata":{}},{"cell_type":"code","source":"\nplt.figure(figsize=(12, 10))\ncorr = merged_data[['Rs', 'Ms', 'Ts', 'Mp', 'e', 'P', 'sma', 'i']].corr()\nsns.heatmap(corr, annot=True, cmap='coolwarm', center=0)\nplt.title('Correlation Heatmap of Star and Planet Characteristics')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-27T02:56:40.807687Z","iopub.execute_input":"2025-06-27T02:56:40.807924Z","iopub.status.idle":"2025-06-27T02:56:41.119093Z","shell.execute_reply.started":"2025-06-27T02:56:40.807901Z","shell.execute_reply":"2025-06-27T02:56:41.113602Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 9. Interactive Parallel Coordinates Plot","metadata":{}},{"cell_type":"code","source":"\nfig = px.parallel_coordinates(merged_data, \n                             color='Ts',\n                             dimensions=['Rs', 'Ms', 'Ts', 'Mp', 'P', 'sma'],\n                             labels={'Rs': 'Star Radius', 'Ms': 'Star Mass', \n                                     'Ts': 'Star Temp', 'Mp': 'Planet Mass',\n                                     'P': 'Orbital Period', 'sma': 'Semi-major Axis'},\n                             title='Parallel Coordinates Plot of System Characteristics')\nfig.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-27T02:56:41.120731Z","iopub.execute_input":"2025-06-27T02:56:41.120939Z","iopub.status.idle":"2025-06-27T02:56:41.210286Z","shell.execute_reply.started":"2025-06-27T02:56:41.120918Z","shell.execute_reply":"2025-06-27T02:56:41.205812Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 10. Orbital Parameter Visualization","metadata":{}},{"cell_type":"code","source":"\nfig = plt.figure(figsize=(15, 5))\nplt.subplot(1, 3, 1)\nsns.histplot(merged_data['P'], bins=20, kde=True)\nplt.title('Orbital Period Distribution')\n\nplt.subplot(1, 3, 2)\nsns.scatterplot(data=merged_data, x='P', y='sma', hue='Mp', size='Ms')\nplt.title('Orbital Period vs Semi-major Axis')\n\nplt.subplot(1, 3, 3)\nsns.scatterplot(data=merged_data, x='i', y='e', hue='Ts', size='Rs')\nplt.title('Inclination vs Eccentricity')\nplt.tight_layout()\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-27T02:56:41.21214Z","iopub.execute_input":"2025-06-27T02:56:41.212374Z","iopub.status.idle":"2025-06-27T02:56:42.103367Z","shell.execute_reply.started":"2025-06-27T02:56:41.212352Z","shell.execute_reply":"2025-06-27T02:56:42.098902Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# D. Adavance Visualization","metadata":{}},{"cell_type":"markdown","source":"## 0. Imports","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D\nimport seaborn as sns\nimport plotly.express as px\nimport plotly.graph_objects as go\nfrom ipywidgets import interact, interactive, fixed, interact_manual\nimport ipywidgets as widgets\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.decomposition import PCA\nfrom sklearn.manifold import TSNE\n\n\nwl_columns = [col for col in train.columns if col.startswith('wl_')]\n\n!pip install -q PyWavelets\nimport pywt","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-27T02:56:42.10524Z","iopub.execute_input":"2025-06-27T02:56:42.105468Z","iopub.status.idle":"2025-06-27T02:56:45.878024Z","shell.execute_reply.started":"2025-06-27T02:56:42.105447Z","shell.execute_reply":"2025-06-27T02:56:45.872732Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 1. Advanced Interactive 3D System Explorer","metadata":{}},{"cell_type":"code","source":"\ndef create_3d_explorer():\n    fig = go.Figure()\n    \n    # Add star systems\n    fig.add_trace(go.Scatter3d(\n        x=merged_data['Rs'],\n        y=merged_data['Ms'],\n        z=merged_data['Ts'],\n        mode='markers',\n        marker=dict(\n            size=merged_data['Mp']*2,\n            color=merged_data['P'],\n            colorscale='Viridis',\n            opacity=0.8,\n            colorbar=dict(title='Orbital Period')\n        ),\n        text=[f\"Planet ID: {pid}<br>Mass: {mp} Mj<br>Period: {p} days\" \n              for pid, mp, p in zip(merged_data['planet_id'], merged_data['Mp'], merged_data['P'])],\n        hoverinfo='text',\n        name='Star Systems'\n    ))\n    \n    # Add orbital circles\n    for _, row in merged_data.iterrows():\n        theta = np.linspace(0, 2*np.pi, 100)\n        x = row['Rs'] + row['sma'] * np.cos(theta)\n        y = row['Ms'] + row['sma'] * np.sin(theta) * np.cos(np.radians(row['i']))\n        z = row['Ts'] + row['sma'] * np.sin(theta) * np.sin(np.radians(row['i']))\n        \n        fig.add_trace(go.Scatter3d(\n            x=x, y=y, z=z,\n            mode='lines',\n            line=dict(width=1, color='rgba(150,150,150,0.5)'),\n            showlegend=False,\n            hoverinfo='none'\n        ))\n    \n    fig.update_layout(\n        scene=dict(\n            xaxis_title='Star Radius (Rs)',\n            yaxis_title='Star Mass (Ms)',\n            zaxis_title='Star Temp (Ts)',\n            camera=dict(eye=dict(x=1.5, y=1.5, z=0.8))\n        ),\n        title='Interactive 3D Star System Explorer with Orbits',\n        height=800\n    )\n    return fig\n\nfig_3d = create_3d_explorer()\nfig_3d.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-27T02:56:45.879282Z","iopub.execute_input":"2025-06-27T02:56:45.879564Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 2. Wavelet Transform Visualization","metadata":{}},{"cell_type":"code","source":"def plot_wavelet(planet_id):\n    data = train[train['planet_id'] == planet_id][wl_columns].values.flatten()\n    scales = np.arange(1, 128)\n    coefficients, frequencies = pywt.cwt(data, scales, 'morl')\n    \n    plt.figure(figsize=(12, 6))\n    plt.imshow(np.abs(coefficients), extent=[0, len(data), 1, 128], \n               cmap='viridis', aspect='auto', vmax=abs(coefficients).max(), \n               vmin=-abs(coefficients).max())\n    plt.colorbar(label='Magnitude')\n    plt.title(f'Continuous Wavelet Transform - Planet {planet_id}')\n    plt.ylabel('Scale')\n    plt.xlabel('Wavelength Index')\n    plt.show()\n\nplot_wavelet(merged_data['planet_id'].iloc[0])","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 3. t-SNE and UMAP Projections","metadata":{}},{"cell_type":"code","source":"!pip install -q umap-learn\n\nimport umap\n\ndef plot_manifold_projections():\n    from mpl_toolkits.axes_grid1 import make_axes_locatable  # <-- Add this import\n    \n    scaler = StandardScaler()\n    wl_scaled = scaler.fit_transform(train[wl_columns])\n    \n    # t-SNE\n    tsne = TSNE(n_components=2, perplexity=30, random_state=42)\n    tsne_results = tsne.fit_transform(wl_scaled)\n    \n    # UMAP\n    reducer = umap.UMAP(random_state=42)\n    umap_results = reducer.fit_transform(wl_scaled)\n    \n    fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(18, 8))\n    \n    sc1 = ax1.scatter(tsne_results[:, 0], tsne_results[:, 1], \n                     c=merged_data['Ts'], cmap='plasma', s=merged_data['Mp']*20)\n    ax1.set_title('t-SNE Projection (Colored by Star Temperature)')\n    ax1.set_xlabel('t-SNE 1')\n    ax1.set_ylabel('t-SNE 2')\n    \n    # Create divider for existing axes\n    divider = make_axes_locatable(ax1)\n    cax = divider.append_axes(\"right\", size=\"5%\", pad=0.05)\n    plt.colorbar(sc1, cax=cax, label='Star Temperature (K)')\n    \n    sc2 = ax2.scatter(umap_results[:, 0], umap_results[:, 1], \n                     c=merged_data['Mp'], cmap='viridis', s=merged_data['Rs']*20)\n    ax2.set_title('UMAP Projection (Colored by Planet Mass)')\n    ax2.set_xlabel('UMAP 1')\n    ax2.set_ylabel('UMAP 2')\n    \n    # Create divider for second axes\n    divider2 = make_axes_locatable(ax2)\n    cax2 = divider2.append_axes(\"right\", size=\"5%\", pad=0.05)\n    plt.colorbar(sc2, cax=cax2, label='Planet Mass (Mj)')\n    \n    plt.tight_layout()\n    plt.show()\n\nplot_manifold_projections()","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 4. Interactive Bokeh Network Graph","metadata":{}},{"cell_type":"markdown","source":"## 5. Radial Chart","metadata":{}},{"cell_type":"code","source":"def plot_radial_chart(planet_id):\n    selected = merged_data[merged_data['planet_id'] == planet_id].iloc[0]\n    \n    categories = ['Rs', 'Ms', 'Ts', 'Mp', 'P', 'sma', 'i']\n    values = selected[categories].values\n    values_normalized = values / values.max()\n    \n    N = len(categories)\n    angles = np.linspace(0, 2*np.pi, N, endpoint=False).tolist()\n    angles += angles[:1]\n    values_normalized = np.append(values_normalized, values_normalized[:1])\n    \n    fig = plt.figure(figsize=(8, 8))\n    ax = fig.add_subplot(111, polar=True)\n    ax.plot(angles, values_normalized, 'o-', linewidth=2)\n    ax.fill(angles, values_normalized, alpha=0.25)\n    \n    ax.set_xticks(angles[:-1])\n    ax.set_xticklabels(categories)\n    ax.set_title(f'Radial Chart of System Parameters - Planet {planet_id}', size=15, y=1.1)\n    ax.set_rlabel_position(30)\n    plt.tight_layout()\n    plt.show()\n\nplot_radial_chart(merged_data['planet_id'].iloc[0])","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 6. Interactive HoloViews Dashboard","metadata":{}},{"cell_type":"code","source":"!pip install -q holoviews\n\nimport holoviews as hv\nhv.extension('bokeh')  # This enables Bokeh rendering\n\ndef create_holoviews_dashboard():\n    # Prepare data\n    scatter_data = merged_data[['Rs', 'Ms', 'Ts', 'Mp', 'P', 'sma', 'i', 'planet_id']]\n    \n    # Create scatter plots\n    scatter1 = hv.Scatter(scatter_data, 'Rs', 'Ms').opts(\n        width=400, height=400, tools=['hover'], size='Mp', color='Ts', cmap='fire', \n        title='Star Radius vs Mass (size=Planet Mass, color=Star Temp)')\n    \n    scatter2 = hv.Scatter(scatter_data, 'P', 'sma').opts(\n        width=400, height=400, tools=['hover'], size='Mp', color='i', cmap='viridis',\n        title='Orbital Period vs SMA (size=Planet Mass, color=Inclination)')\n    \n    # Create histogram\n    hist = hv.Histogram(np.histogram(merged_data['Ts'], bins=20)).opts(\n        width=400, height=400, title='Star Temperature Distribution')\n    \n    # Combine into dashboard\n    dashboard = (scatter1 + scatter2 + hist).cols(2)\n    return dashboard\n\ncreate_holoviews_dashboard()","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 7. Phase Space Visualization","metadata":{}},{"cell_type":"code","source":"\ndef plot_phase_space():\n    fig = plt.figure(figsize=(15, 10))\n    \n    # Create grid\n    gs = fig.add_gridspec(2, 2, width_ratios=[3, 1], height_ratios=[1, 3])\n    \n    # Main scatter plot\n    ax = fig.add_subplot(gs[1, 0])\n    sc = ax.scatter(merged_data['P'], merged_data['sma'], \n                   c=merged_data['Ts'], s=merged_data['Mp']*50, \n                   cmap='plasma', alpha=0.7)\n    ax.set_xlabel('Orbital Period (days)')\n    ax.set_ylabel('Semi-major Axis (AU)')\n    ax.set_title('Phase Space of Exoplanet Systems')\n    \n    # Marginal distributions\n    ax_top = fig.add_subplot(gs[0, 0], sharex=ax)\n    sns.kdeplot(data=merged_data, x='P', color='blue', ax=ax_top, fill=True)\n    ax_top.set_yticks([])\n    ax_top.set_ylabel('Density')\n    \n    ax_right = fig.add_subplot(gs[1, 1], sharey=ax)\n    sns.kdeplot(data=merged_data, y='sma', color='red', ax=ax_right, fill=True)\n    ax_right.set_xticks([])\n    ax_right.set_xlabel('Density')\n    \n    # Colorbar\n    cax = fig.add_axes([0.92, 0.3, 0.02, 0.4])\n    plt.colorbar(sc, cax=cax, label='Star Temperature (K)')\n    \n    plt.tight_layout()\n    plt.show()\nprint(\"\\n## 7. Phase Space Visualization ##\")\nplot_phase_space()","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## 8. Interactive Parameter Space Explorer","metadata":{}},{"cell_type":"code","source":"\n@interact(\n    x_axis=widgets.Dropdown(options=['Rs', 'Ms', 'Ts', 'Mp', 'P', 'sma', 'i'], value='Rs'),\n    y_axis=widgets.Dropdown(options=['Rs', 'Ms', 'Ts', 'Mp', 'P', 'sma', 'i'], value='Ms'),\n    color_by=widgets.Dropdown(options=['Ts', 'Mp', 'P', 'sma', 'i', 'e'], value='Ts'),\n    size_by=widgets.Dropdown(options=['None', 'Mp', 'Rs', 'Ms', 'P', 'sma'], value='Mp')\n)\ndef interactive_scatter(x_axis, y_axis, color_by, size_by):\n    size = merged_data[size_by]*20 if size_by != 'None' else 50\n    \n    plt.figure(figsize=(10, 8))\n    sc = plt.scatter(merged_data[x_axis], merged_data[y_axis], \n                    c=merged_data[color_by], s=size, \n                    cmap='viridis', alpha=0.7)\n    plt.colorbar(sc, label=color_by)\n    plt.xlabel(x_axis)\n    plt.ylabel(y_axis)\n    plt.title(f'{y_axis} vs {x_axis} (Color: {color_by}, Size: {size_by if size_by != \"None\" else \"Fixed\"})')\n    plt.grid(True)\n    plt.show()\n\nprint(\"\\n## 8. Interactive Parameter Explorer - Use the widgets below ##\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"<div style=\"border: 2px solid #4CAF50; padding: 15px; border-radius: 10px; background-color: #ffffff; box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);\">\n\n<h2 style=\"color: #4CAF50; text-align: center;\">Thank You! 🎉</h2>\n\n<p style=\"font-size: 16px; text-align: justify;\">\nThank you for exploring my notebook! I hope you found it insightful and helpful.  \nIf you have any feedback, I’d love to hear from you!  \nYour support and comments mean a lot to me. 😊\n</p>\n\n<div style=\"text-align: left; margin: 10px 0;\">\n    <img src=\"https://i.pinimg.com/236x/90/e8/ff/90e8ff78f7bef8490e0ab9cb5b83ee0f.jpg\" alt=\"Thank You Image\" style=\"border-radius: 0%; border: 2px solid #ffffff;\">\n</div>\n\n<h3 style=\"color: #4CAF50;\">🌐 Useful Links:</h3>\n<ul style=\"font-size: 16px;\">\n  <li><a href=\"https://www.kaggle.com/samasiayushman\" target=\"_blank\" style=\"color: #2196F3;\">My Kaggle Profile</a></li>\n  <li><a href=\"https://github.com/Hariswar8018\" target=\"_blank\" style=\"color: #2196F3;\">Notebook Code Repository</a></li>\n</ul>\n\n<p style=\"font-size: 16px; text-align: center; font-weight: bold;\">\n✨ Don’t forget to upvote if you found this notebook helpful! ✨\n</p>\n\n</div>\n","metadata":{}}]}