From 305dd1b044e9ccf8a3fa626f2245aae068a36805 Mon Sep 17 00:00:00 2001 From: VARUNSHIYAM <138989960+Varunshiyam@users.noreply.github.com> Date: Sun, 10 Nov 2024 08:22:35 +0530 Subject: [PATCH 1/2] fixes 861 --- .../stars-classification.ipynb | 1025 +++++++++++++++++ 1 file changed, 1025 insertions(+) create mode 100644 Prediction Models/Stars_Classification_Model/stars-classification.ipynb diff --git a/Prediction Models/Stars_Classification_Model/stars-classification.ipynb b/Prediction Models/Stars_Classification_Model/stars-classification.ipynb new file mode 100644 index 00000000..d235c6ff --- /dev/null +++ b/Prediction Models/Stars_Classification_Model/stars-classification.ipynb @@ -0,0 +1,1025 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "51cd8e4a", + "metadata": { + "id": "0qGrVrvcp--0", + "papermill": { + "duration": 0.007509, + "end_time": "2023-03-09T10:46:15.583686", + "exception": false, + "start_time": "2023-03-09T10:46:15.576177", + "status": "completed" + }, + "tags": [] + }, + "source": [ + "# **Stars Classification**" + ] + }, + { + "cell_type": "markdown", + "id": "28d99cba", + "metadata": { + "id": "99ybK23wexQB", + "papermill": { + "duration": 0.005634, + "end_time": "2023-03-09T10:46:15.596050", + "exception": false, + "start_time": "2023-03-09T10:46:15.590416", + "status": "completed" + }, + "tags": [] + }, + "source": [ + "This is a dataset consisting of several features of stars.\n", + "\n", + "Some of them are:\n", + "\n", + "- Absolute Temperature (in K)\n", + "- Relative Luminosity (L/Lo)\n", + "- Relative Radius (R/Ro)\n", + "- Absolute Magnitude (Mv)\n", + "- Star Color (white,Red,Blue,Yellow,yellow-orange etc)\n", + "- Spectral Class (O,B,A,F,G,K,,M)\n", + "- Star Type **(Red Dwarf, Brown Dwarf, White Dwarf, Main Sequence , SuperGiants, HyperGiants)**\n", + "- Lo = 3.828 x 10^26 Watts (Avg Luminosity of Sun)\n", + "- Ro = 6.9551 x 10^8 m (Avg Radius of Sun)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "41ecf60a", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:15.609865Z", + "iopub.status.busy": "2023-03-09T10:46:15.609398Z", + "iopub.status.idle": "2023-03-09T10:46:15.619817Z", + "shell.execute_reply": "2023-03-09T10:46:15.618591Z" + }, + "id": "H2oCFJGuy37u", + "papermill": { + "duration": 0.020493, + "end_time": "2023-03-09T10:46:15.622480", + "exception": false, + "start_time": "2023-03-09T10:46:15.601987", + "status": "completed" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "# import library\n", + "import pandas as pd\n", + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "8eb67146", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:15.636860Z", + "iopub.status.busy": "2023-03-09T10:46:15.636026Z", + "iopub.status.idle": "2023-03-09T10:46:16.065580Z", + "shell.execute_reply": "2023-03-09T10:46:16.064219Z" + }, + "id": "pvrtYImUy7hC", + "papermill": { + "duration": 0.439824, + "end_time": "2023-03-09T10:46:16.068421", + "exception": false, + "start_time": "2023-03-09T10:46:15.628597", + "status": "completed" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "# import data\n", + "star = pd.read_csv ('https://github.com/YBIFoundation/Dataset/raw/main/Stars.csv')" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "370e9190", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:16.082890Z", + "iopub.status.busy": "2023-03-09T10:46:16.081732Z", + "iopub.status.idle": "2023-03-09T10:46:16.111812Z", + "shell.execute_reply": "2023-03-09T10:46:16.110574Z" + }, + "id": "ltkYXmdz-_z3", + "outputId": "65f6131d-230b-491f-e662-38ef3296ee70", + "papermill": { + "duration": 0.040736, + "end_time": "2023-03-09T10:46:16.115161", + "exception": false, + "start_time": "2023-03-09T10:46:16.074425", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Temperature (K)Luminosity (L/Lo)Radius (R/Ro)Absolute magnitude (Mv)Star typeStar categoryStar colorSpectral Class
030680.0024000.170016.120Brown DwarfRedM
130420.0005000.154216.600Brown DwarfRedM
226000.0003000.102018.700Brown DwarfRedM
328000.0002000.160016.650Brown DwarfRedM
419390.0001380.103020.060Brown DwarfRedM
\n", + "
" + ], + "text/plain": [ + " Temperature (K) Luminosity (L/Lo) Radius (R/Ro) Absolute magnitude (Mv) \\\n", + "0 3068 0.002400 0.1700 16.12 \n", + "1 3042 0.000500 0.1542 16.60 \n", + "2 2600 0.000300 0.1020 18.70 \n", + "3 2800 0.000200 0.1600 16.65 \n", + "4 1939 0.000138 0.1030 20.06 \n", + "\n", + " Star type Star category Star color Spectral Class \n", + "0 0 Brown Dwarf Red M \n", + "1 0 Brown Dwarf Red M \n", + "2 0 Brown Dwarf Red M \n", + "3 0 Brown Dwarf Red M \n", + "4 0 Brown Dwarf Red M " + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "star.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "dcbff7e1", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:16.129558Z", + "iopub.status.busy": "2023-03-09T10:46:16.129164Z", + "iopub.status.idle": "2023-03-09T10:46:16.155166Z", + "shell.execute_reply": "2023-03-09T10:46:16.153515Z" + }, + "id": "f0XHmtvL_CGZ", + "outputId": "4fe51aba-15f6-4863-efe5-af86ba344be0", + "papermill": { + "duration": 0.036582, + "end_time": "2023-03-09T10:46:16.157996", + "exception": false, + "start_time": "2023-03-09T10:46:16.121414", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 240 entries, 0 to 239\n", + "Data columns (total 8 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 Temperature (K) 240 non-null int64 \n", + " 1 Luminosity (L/Lo) 240 non-null float64\n", + " 2 Radius (R/Ro) 240 non-null float64\n", + " 3 Absolute magnitude (Mv) 240 non-null float64\n", + " 4 Star type 240 non-null int64 \n", + " 5 Star category 240 non-null object \n", + " 6 Star color 240 non-null object \n", + " 7 Spectral Class 240 non-null object \n", + "dtypes: float64(3), int64(2), object(3)\n", + "memory usage: 15.1+ KB\n" + ] + } + ], + "source": [ + "star.info()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "189a3983", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:16.173453Z", + "iopub.status.busy": "2023-03-09T10:46:16.172549Z", + "iopub.status.idle": "2023-03-09T10:46:16.204642Z", + "shell.execute_reply": "2023-03-09T10:46:16.203325Z" + }, + "id": "tmpkna_P4Wnn", + "outputId": "89f9b65e-0636-4022-8721-13fbd9a9177f", + "papermill": { + "duration": 0.04307, + "end_time": "2023-03-09T10:46:16.207436", + "exception": false, + "start_time": "2023-03-09T10:46:16.164366", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Temperature (K)Luminosity (L/Lo)Radius (R/Ro)Absolute magnitude (Mv)Star type
count240.000000240.000000240.000000240.000000240.000000
mean10497.462500107188.361635237.1577814.3823962.500000
std9552.425037179432.244940517.15576310.5325121.711394
min1939.0000000.0000800.008400-11.9200000.000000
25%3344.2500000.0008650.102750-6.2325001.000000
50%5776.0000000.0705000.7625008.3130002.500000
75%15055.500000198050.00000042.75000013.6975004.000000
max40000.000000849420.0000001948.50000020.0600005.000000
\n", + "
" + ], + "text/plain": [ + " Temperature (K) Luminosity (L/Lo) Radius (R/Ro) \\\n", + "count 240.000000 240.000000 240.000000 \n", + "mean 10497.462500 107188.361635 237.157781 \n", + "std 9552.425037 179432.244940 517.155763 \n", + "min 1939.000000 0.000080 0.008400 \n", + "25% 3344.250000 0.000865 0.102750 \n", + "50% 5776.000000 0.070500 0.762500 \n", + "75% 15055.500000 198050.000000 42.750000 \n", + "max 40000.000000 849420.000000 1948.500000 \n", + "\n", + " Absolute magnitude (Mv) Star type \n", + "count 240.000000 240.000000 \n", + "mean 4.382396 2.500000 \n", + "std 10.532512 1.711394 \n", + "min -11.920000 0.000000 \n", + "25% -6.232500 1.000000 \n", + "50% 8.313000 2.500000 \n", + "75% 13.697500 4.000000 \n", + "max 20.060000 5.000000 " + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "star.describe()" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "1d1512c6", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:16.223548Z", + "iopub.status.busy": "2023-03-09T10:46:16.222295Z", + "iopub.status.idle": "2023-03-09T10:46:16.230443Z", + "shell.execute_reply": "2023-03-09T10:46:16.229442Z" + }, + "id": "G_8EXMzWU5WW", + "outputId": "e6a1de0f-d1ef-44d6-ccec-d7b0a89f58fe", + "papermill": { + "duration": 0.018621, + "end_time": "2023-03-09T10:46:16.232819", + "exception": false, + "start_time": "2023-03-09T10:46:16.214198", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "Index(['Temperature (K)', 'Luminosity (L/Lo)', 'Radius (R/Ro)',\n", + " 'Absolute magnitude (Mv)', 'Star type', 'Star category', 'Star color',\n", + " 'Spectral Class'],\n", + " dtype='object')" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "star.columns" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "44e05509", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:16.249111Z", + "iopub.status.busy": "2023-03-09T10:46:16.247837Z", + "iopub.status.idle": "2023-03-09T10:46:16.263577Z", + "shell.execute_reply": "2023-03-09T10:46:16.262182Z" + }, + "id": "cXKbh7DzAMZ9", + "outputId": "3527f48f-da5d-4ab2-94b3-9b04a0e911dd", + "papermill": { + "duration": 0.027027, + "end_time": "2023-03-09T10:46:16.266469", + "exception": false, + "start_time": "2023-03-09T10:46:16.239442", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "Spectral Class\n", + "M 111\n", + "B 46\n", + "O 40\n", + "A 19\n", + "F 17\n", + "K 6\n", + "G 1\n", + "dtype: int64" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# number of categories\n", + "star[['Spectral Class']].value_counts()" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "42fafea8", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:16.282626Z", + "iopub.status.busy": "2023-03-09T10:46:16.281702Z", + "iopub.status.idle": "2023-03-09T10:46:16.289941Z", + "shell.execute_reply": "2023-03-09T10:46:16.288927Z" + }, + "id": "d9Y-SSJ3zxue", + "papermill": { + "duration": 0.019146, + "end_time": "2023-03-09T10:46:16.292398", + "exception": false, + "start_time": "2023-03-09T10:46:16.273252", + "status": "completed" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "# encoding\n", + "star.replace({'Spectral Class':{'M':0, 'A':1, 'B':1, 'F':1, 'O':1, 'K':1, 'G':1 }}, inplace=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "20e65c1d", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:16.307999Z", + "iopub.status.busy": "2023-03-09T10:46:16.307544Z", + "iopub.status.idle": "2023-03-09T10:46:16.317923Z", + "shell.execute_reply": "2023-03-09T10:46:16.316821Z" + }, + "id": "d7s9KFqRApFa", + "outputId": "ed01dd5d-0192-4105-d22b-2f459b88550b", + "papermill": { + "duration": 0.021162, + "end_time": "2023-03-09T10:46:16.320287", + "exception": false, + "start_time": "2023-03-09T10:46:16.299125", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "Star type\n", + "0 40\n", + "1 40\n", + "2 40\n", + "3 40\n", + "4 40\n", + "5 40\n", + "dtype: int64" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# number of categories\n", + "star[['Star type']].value_counts()" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "6c820ad3", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:16.337742Z", + "iopub.status.busy": "2023-03-09T10:46:16.336499Z", + "iopub.status.idle": "2023-03-09T10:46:16.344742Z", + "shell.execute_reply": "2023-03-09T10:46:16.343785Z" + }, + "id": "gxMdpWGrtxSJ", + "papermill": { + "duration": 0.020106, + "end_time": "2023-03-09T10:46:16.347265", + "exception": false, + "start_time": "2023-03-09T10:46:16.327159", + "status": "completed" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "# encoding\n", + "star.replace({'Star color':{ 'Red':0, 'Yellow':1, 'White':2, 'White ': 2, 'Blue ':3, 'Blue':3 }}, inplace=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "1c8ae8be", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:16.363573Z", + "iopub.status.busy": "2023-03-09T10:46:16.362709Z", + "iopub.status.idle": "2023-03-09T10:46:16.373924Z", + "shell.execute_reply": "2023-03-09T10:46:16.372852Z" + }, + "id": "BrzFVAHz_Xpg", + "outputId": "f0864219-1346-4788-8c30-570efa3dbef2", + "papermill": { + "duration": 0.022135, + "end_time": "2023-03-09T10:46:16.376341", + "exception": false, + "start_time": "2023-03-09T10:46:16.354206", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "Star color \n", + "0 112\n", + "3 56\n", + "Blue-white 26\n", + "Blue White 10\n", + "yellow-white 8\n", + "2 7\n", + "Blue white 3\n", + "white 3\n", + "Yellowish White 3\n", + "Whitish 2\n", + "yellowish 2\n", + "Orange 2\n", + "White-Yellow 1\n", + "Pale yellow orange 1\n", + "Yellowish 1\n", + "Blue-White 1\n", + "Blue white 1\n", + "Orange-Red 1\n", + "dtype: int64" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# number of categories\n", + "star[['Star color']].value_counts()" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "a1248243", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:16.392863Z", + "iopub.status.busy": "2023-03-09T10:46:16.392021Z", + "iopub.status.idle": "2023-03-09T10:46:16.399398Z", + "shell.execute_reply": "2023-03-09T10:46:16.398165Z" + }, + "id": "Kwc4B6zoWYUg", + "papermill": { + "duration": 0.018759, + "end_time": "2023-03-09T10:46:16.402003", + "exception": false, + "start_time": "2023-03-09T10:46:16.383244", + "status": "completed" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "# define target and features\n", + "y = star['Spectral Class']\n", + "X = star[['Temperature (K)', 'Luminosity (L/Lo)', 'Radius (R/Ro)',\n", + " 'Absolute magnitude (Mv)']]" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "a84d18e5", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:16.418550Z", + "iopub.status.busy": "2023-03-09T10:46:16.418155Z", + "iopub.status.idle": "2023-03-09T10:46:17.609273Z", + "shell.execute_reply": "2023-03-09T10:46:17.607830Z" + }, + "id": "Uh4Qx-WmXbcE", + "papermill": { + "duration": 1.202641, + "end_time": "2023-03-09T10:46:17.612174", + "exception": false, + "start_time": "2023-03-09T10:46:16.409533", + "status": "completed" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "# split\n", + "from sklearn.model_selection import train_test_split\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, train_size = 0.8, random_state = 200)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "cf4ebfd8", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:17.629173Z", + "iopub.status.busy": "2023-03-09T10:46:17.628418Z", + "iopub.status.idle": "2023-03-09T10:46:17.747645Z", + "shell.execute_reply": "2023-03-09T10:46:17.746414Z" + }, + "id": "B4G93PVhYjyl", + "papermill": { + "duration": 0.131497, + "end_time": "2023-03-09T10:46:17.751168", + "exception": false, + "start_time": "2023-03-09T10:46:17.619671", + "status": "completed" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "# select model\n", + "from sklearn.linear_model import LogisticRegression\n", + "model = LogisticRegression()" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "4e7b17c8", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:17.768438Z", + "iopub.status.busy": "2023-03-09T10:46:17.767011Z", + "iopub.status.idle": "2023-03-09T10:46:17.811396Z", + "shell.execute_reply": "2023-03-09T10:46:17.809968Z" + }, + "id": "ZNNabAuxlZj8", + "outputId": "84de4853-cca2-4315-80a4-e8ddd6a23c1f", + "papermill": { + "duration": 0.055817, + "end_time": "2023-03-09T10:46:17.814067", + "exception": false, + "start_time": "2023-03-09T10:46:17.758250", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "LogisticRegression()" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# train model\n", + "model.fit(X_train,y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "33fe201a", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:17.830765Z", + "iopub.status.busy": "2023-03-09T10:46:17.830276Z", + "iopub.status.idle": "2023-03-09T10:46:17.837787Z", + "shell.execute_reply": "2023-03-09T10:46:17.836418Z" + }, + "id": "9zj_do5MZ7ro", + "papermill": { + "duration": 0.018863, + "end_time": "2023-03-09T10:46:17.840356", + "exception": false, + "start_time": "2023-03-09T10:46:17.821493", + "status": "completed" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "# predict\n", + "y_pred = model.predict(X_test)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "0d13e23b", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:17.858009Z", + "iopub.status.busy": "2023-03-09T10:46:17.856480Z", + "iopub.status.idle": "2023-03-09T10:46:17.864644Z", + "shell.execute_reply": "2023-03-09T10:46:17.863717Z" + }, + "id": "fYxaGZZv1bVe", + "outputId": "268352de-c163-4970-98ed-d396fb45ccd8", + "papermill": { + "duration": 0.019512, + "end_time": "2023-03-09T10:46:17.867069", + "exception": false, + "start_time": "2023-03-09T10:46:17.847557", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "array([0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1,\n", + " 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0,\n", + " 1, 1, 1, 1])" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "y_pred" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "74cb8fb4", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:17.884345Z", + "iopub.status.busy": "2023-03-09T10:46:17.882887Z", + "iopub.status.idle": "2023-03-09T10:46:17.889019Z", + "shell.execute_reply": "2023-03-09T10:46:17.888053Z" + }, + "id": "LeG8eFnKAUII", + "papermill": { + "duration": 0.017049, + "end_time": "2023-03-09T10:46:17.891369", + "exception": false, + "start_time": "2023-03-09T10:46:17.874320", + "status": "completed" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "# import function\n", + "from sklearn.metrics import confusion_matrix, classification_report" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "86490c26", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:17.907582Z", + "iopub.status.busy": "2023-03-09T10:46:17.907168Z", + "iopub.status.idle": "2023-03-09T10:46:17.919067Z", + "shell.execute_reply": "2023-03-09T10:46:17.917665Z" + }, + "id": "BzrhbXQAmR1x", + "outputId": "9d2af00a-d29c-4890-b6e2-fcec205a54a9", + "papermill": { + "duration": 0.023062, + "end_time": "2023-03-09T10:46:17.921608", + "exception": false, + "start_time": "2023-03-09T10:46:17.898546", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[14, 4],\n", + " [ 1, 29]])" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "confusion_matrix(y_test,y_pred)" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "a58d5e5b", + "metadata": { + "execution": { + "iopub.execute_input": "2023-03-09T10:46:17.938715Z", + "iopub.status.busy": "2023-03-09T10:46:17.938044Z", + "iopub.status.idle": "2023-03-09T10:46:17.948744Z", + "shell.execute_reply": "2023-03-09T10:46:17.947106Z" + }, + "id": "10bskobTmUIn", + "outputId": "40f826a2-cec8-437a-b210-7dceb19a4721", + "papermill": { + "duration": 0.023255, + "end_time": "2023-03-09T10:46:17.952408", + "exception": false, + "start_time": "2023-03-09T10:46:17.929153", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " precision recall f1-score support\n", + "\n", + " 0 0.93 0.78 0.85 18\n", + " 1 0.88 0.97 0.92 30\n", + "\n", + " accuracy 0.90 48\n", + " macro avg 0.91 0.87 0.88 48\n", + "weighted avg 0.90 0.90 0.89 48\n", + "\n" + ] + } + ], + "source": [ + "print(classification_report(y_test,y_pred))" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.7" + }, + "papermill": { + "default_parameters": {}, + "duration": 14.006381, + "end_time": "2023-03-09T10:46:18.799231", + "environment_variables": {}, + "exception": null, + "input_path": "__notebook__.ipynb", + "output_path": "__notebook__.ipynb", + "parameters": {}, + "start_time": "2023-03-09T10:46:04.792850", + "version": "2.4.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 68fb187973ec919764e8f4f1511c0ac2819c014f Mon Sep 17 00:00:00 2001 From: VARUNSHIYAM <138989960+Varunshiyam@users.noreply.github.com> Date: Sun, 10 Nov 2024 08:24:55 +0530 Subject: [PATCH 2/2] Create Readme.md --- .../Stars_Classification_Model/Readme.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Prediction Models/Stars_Classification_Model/Readme.md diff --git a/Prediction Models/Stars_Classification_Model/Readme.md b/Prediction Models/Stars_Classification_Model/Readme.md new file mode 100644 index 00000000..fbb81a95 --- /dev/null +++ b/Prediction Models/Stars_Classification_Model/Readme.md @@ -0,0 +1,18 @@ +# Star Classification System + +## Project Overview + +This project uses machine learning to classify stars into specific types based on their features. The system is designed to analyze astronomical data and assign star classes accurately. This project can assist astronomers and researchers in understanding star distributions and characteristics in various datasets. + +## Problem Statement + +Classifying stars accurately is essential in astronomical research, enabling better understanding of star properties, distributions, and behaviors. This project aims to create a classification model that can identify star types based on their features, such as temperature, luminosity, and radius. By accurately categorizing stars, we can gain insights into stellar evolution and structure. + +## Features + +- **Data Preprocessing**: Cleaning and preparing data for training. +- **Model Training**: Using machine learning algorithms to classify star types. +- **Model Evaluation**: Measuring the model’s performance with accuracy and other metrics. +- **Data Visualization**: Visualizing the classification results for interpretability. + +