[d7f708]: / health-monitoring-systems.ipynb

Download this file

1 lines (1 with data), 21.1 kB

{"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"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"},"colab":{"provenance":[]},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":2403058,"sourceType":"datasetVersion","datasetId":1453292},{"sourceId":9531002,"sourceType":"datasetVersion","datasetId":5804342},{"sourceId":9531017,"sourceType":"datasetVersion","datasetId":5804353}],"dockerImageVersionId":30775,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.model_selection import train_test_split\nfrom sklearn import svm\nfrom sklearn.metrics import accuracy_score\nfrom sklearn.svm import SVC\n","metadata":{"id":"hkZpUV0mteme","execution":{"iopub.status.busy":"2024-10-03T06:53:17.609468Z","iopub.execute_input":"2024-10-03T06:53:17.609941Z","iopub.status.idle":"2024-10-03T06:53:17.615834Z","shell.execute_reply.started":"2024-10-03T06:53:17.609898Z","shell.execute_reply":"2024-10-03T06:53:17.61456Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"\nHealth_dataset = pd.read_csv('/kaggle/input/kaggle-input/Health Monitor Dataset.csv')\n","metadata":{"id":"OUjK3iTLvtss","execution":{"iopub.status.busy":"2024-10-03T06:53:17.618106Z","iopub.execute_input":"2024-10-03T06:53:17.618646Z","iopub.status.idle":"2024-10-03T06:53:17.641989Z","shell.execute_reply.started":"2024-10-03T06:53:17.618594Z","shell.execute_reply":"2024-10-03T06:53:17.640729Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"Health_dataset.head()","metadata":{"id":"q00y738KwLB3","outputId":"7804d4d1-ff89-40f8-a4f1-6b168cb9f430","execution":{"iopub.status.busy":"2024-10-03T06:53:17.643628Z","iopub.execute_input":"2024-10-03T06:53:17.644305Z","iopub.status.idle":"2024-10-03T06:53:17.663271Z","shell.execute_reply.started":"2024-10-03T06:53:17.644264Z","shell.execute_reply":"2024-10-03T06:53:17.662166Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"Health_dataset.shape","metadata":{"id":"IERvTxlhyP0n","outputId":"9c6c03bf-150b-419c-9ace-f7a6597928cc","execution":{"iopub.status.busy":"2024-10-03T06:53:17.664716Z","iopub.execute_input":"2024-10-03T06:53:17.665167Z","iopub.status.idle":"2024-10-03T06:53:17.673432Z","shell.execute_reply.started":"2024-10-03T06:53:17.665109Z","shell.execute_reply":"2024-10-03T06:53:17.672186Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"Health_dataset.describe()","metadata":{"id":"47HAdhO2yVgr","outputId":"751e28bb-3914-4290-b2d5-c84bbd6b4757","execution":{"iopub.status.busy":"2024-10-03T06:53:17.675862Z","iopub.execute_input":"2024-10-03T06:53:17.676289Z","iopub.status.idle":"2024-10-03T06:53:17.726653Z","shell.execute_reply.started":"2024-10-03T06:53:17.676251Z","shell.execute_reply":"2024-10-03T06:53:17.725601Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"Health_dataset['Causes Respiratory Imbalance'].value_counts()","metadata":{"id":"7bz0WbdXydSl","outputId":"1ef28acc-451c-4533-af8c-b219e32495eb","execution":{"iopub.status.busy":"2024-10-03T06:53:17.727978Z","iopub.execute_input":"2024-10-03T06:53:17.728331Z","iopub.status.idle":"2024-10-03T06:53:17.737619Z","shell.execute_reply.started":"2024-10-03T06:53:17.728295Z","shell.execute_reply":"2024-10-03T06:53:17.736409Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(Health_dataset.groupby('Causes Respiratory Imbalance').mean())","metadata":{"id":"-friiMFTy5-y","outputId":"ca5bc196-3243-441d-e739-6d91b064f258","execution":{"iopub.status.busy":"2024-10-03T06:53:17.739303Z","iopub.execute_input":"2024-10-03T06:53:17.739796Z","iopub.status.idle":"2024-10-03T06:53:17.760697Z","shell.execute_reply.started":"2024-10-03T06:53:17.739723Z","shell.execute_reply":"2024-10-03T06:53:17.759401Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\nfrom sklearn.preprocessing import LabelEncoder\n\n\nprint(\"Original column names:\", Health_dataset.columns.tolist())\n\n\nle = LabelEncoder()\n\n\nHealth_dataset.rename(columns=lambda x: x.strip(), inplace=True)\n\n\nfor column in Health_dataset.columns:\n    if column in Health_dataset.columns[Health_dataset.columns.duplicated()]:\n        Health_dataset.rename(columns={column: f\"{column}_dup\"}, inplace=True)\n\n\nprint(\"Updated column names:\", Health_dataset.columns.tolist())\n\n\nduplicates_to_drop = [\n    'Cold_dup',\n    'Cough_dup',\n    'Dehydration_dup',\n    'Medicine Overdose_dup',\n    'Acidious_dup',\n    'Dehydration.1',\n    'Medicine Overdose.1',\n    'Acidious.1'\n]\n\n\nHealth_dataset.drop(columns=[col for col in duplicates_to_drop if col in Health_dataset.columns], inplace=True, errors='ignore')\n\nif 'Cold' in Health_dataset.columns:\n    Health_dataset['Cold'] = le.fit_transform(Health_dataset['Cold'])\nif 'Cough' in Health_dataset.columns:\n    Health_dataset['Cough'] = le.fit_transform(Health_dataset['Cough'])\nif 'Dehydration' in Health_dataset.columns:\n    Health_dataset['Dehydration'] = le.fit_transform(Health_dataset['Dehydration'])\nif 'Medicine Overdose' in Health_dataset.columns:\n    Health_dataset['Medicine Overdose'] = le.fit_transform(Health_dataset['Medicine Overdose'])\nif 'Acidious' in Health_dataset.columns:\n    Health_dataset['Acidious'] = le.fit_transform(Health_dataset['Acidious'])\n\nHealth_dataset.head()\n\n","metadata":{"id":"Xl4qsg9H7Zb9","outputId":"0a60e76d-2b7b-4e66-90c2-267b581c225e","execution":{"iopub.status.busy":"2024-10-03T06:53:17.762001Z","iopub.execute_input":"2024-10-03T06:53:17.762386Z","iopub.status.idle":"2024-10-03T06:53:17.794902Z","shell.execute_reply.started":"2024-10-03T06:53:17.762348Z","shell.execute_reply":"2024-10-03T06:53:17.793861Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Define the mapping for the 'Causes Respiratory Imbalance' column\nrespiratory_imbalance_mapping = {\n    'Normal': 0,\n    'Mild': 1,\n    'Severe': 2,\n    'Chronic': 3\n}\n\n# Replace the values using the defined mapping\nHealth_dataset['Causes Respiratory Imbalance'] = Health_dataset['Causes Respiratory Imbalance'].replace(respiratory_imbalance_mapping)\n\n# Display the first few rows to verify changes\nprint(Health_dataset[['Causes Respiratory Imbalance']].head())","metadata":{"id":"i5i8_R-EAG9k","outputId":"34927c39-b050-4130-efae-a1acbb9aa577","execution":{"iopub.status.busy":"2024-10-03T06:53:17.79623Z","iopub.execute_input":"2024-10-03T06:53:17.796582Z","iopub.status.idle":"2024-10-03T06:53:17.811615Z","shell.execute_reply.started":"2024-10-03T06:53:17.796544Z","shell.execute_reply":"2024-10-03T06:53:17.810378Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X=Health_dataset.drop(columns='Causes Respiratory Imbalance',axis=1)\nY=Health_dataset['Causes Respiratory Imbalance']","metadata":{"id":"JBQgfM2Q4DqL","execution":{"iopub.status.busy":"2024-10-03T06:53:17.814146Z","iopub.execute_input":"2024-10-03T06:53:17.814506Z","iopub.status.idle":"2024-10-03T06:53:17.821407Z","shell.execute_reply.started":"2024-10-03T06:53:17.814469Z","shell.execute_reply":"2024-10-03T06:53:17.820274Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X.head()","metadata":{"id":"HMiHU-by8FJE","outputId":"9ab68d5a-cb16-40e6-e163-bb7bb1227475","execution":{"iopub.status.busy":"2024-10-03T06:53:17.823305Z","iopub.execute_input":"2024-10-03T06:53:17.823908Z","iopub.status.idle":"2024-10-03T06:53:17.846863Z","shell.execute_reply.started":"2024-10-03T06:53:17.823857Z","shell.execute_reply":"2024-10-03T06:53:17.845486Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"Y.head()","metadata":{"id":"blD4N_xR8Gy7","outputId":"b4ad304a-a020-457b-bde1-933c27293942","execution":{"iopub.status.busy":"2024-10-03T06:53:17.848326Z","iopub.execute_input":"2024-10-03T06:53:17.848743Z","iopub.status.idle":"2024-10-03T06:53:17.86061Z","shell.execute_reply.started":"2024-10-03T06:53:17.848703Z","shell.execute_reply":"2024-10-03T06:53:17.859407Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"scaler = StandardScaler()","metadata":{"id":"sqFRg2R68KkY","execution":{"iopub.status.busy":"2024-10-03T06:53:17.864083Z","iopub.execute_input":"2024-10-03T06:53:17.86448Z","iopub.status.idle":"2024-10-03T06:53:17.870603Z","shell.execute_reply.started":"2024-10-03T06:53:17.864443Z","shell.execute_reply":"2024-10-03T06:53:17.869521Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"scaler.fit(X)","metadata":{"id":"eHXMRNad8SE1","outputId":"28a98bd3-0dfe-4776-d900-f99c74fd687d","execution":{"iopub.status.busy":"2024-10-03T06:53:17.872054Z","iopub.execute_input":"2024-10-03T06:53:17.872456Z","iopub.status.idle":"2024-10-03T06:53:17.887107Z","shell.execute_reply.started":"2024-10-03T06:53:17.872419Z","shell.execute_reply":"2024-10-03T06:53:17.885749Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(X)\nprint(Y)","metadata":{"id":"TMVIvQck8ULa","outputId":"9ba831c5-4fb1-4065-f1f6-95396dcc5b4b","execution":{"iopub.status.busy":"2024-10-03T06:53:17.88877Z","iopub.execute_input":"2024-10-03T06:53:17.889282Z","iopub.status.idle":"2024-10-03T06:53:17.90234Z","shell.execute_reply.started":"2024-10-03T06:53:17.889229Z","shell.execute_reply":"2024-10-03T06:53:17.900698Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X_train,X_test,Y_train,Y_test= train_test_split(X,Y,test_size=0.8, stratify=Y, random_state=42)","metadata":{"id":"pXh9vWk2jrh0","execution":{"iopub.status.busy":"2024-10-03T06:53:17.903881Z","iopub.execute_input":"2024-10-03T06:53:17.904359Z","iopub.status.idle":"2024-10-03T06:53:17.916094Z","shell.execute_reply.started":"2024-10-03T06:53:17.90431Z","shell.execute_reply":"2024-10-03T06:53:17.915073Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(X.shape,X_train.shape,X_test.shape,Y_train.shape,Y_test.shape)","metadata":{"id":"eBZ87A8U8aH2","outputId":"8a2892b3-3926-4e05-ffd1-ae663a00ed81","execution":{"iopub.status.busy":"2024-10-03T06:53:17.917466Z","iopub.execute_input":"2024-10-03T06:53:17.917872Z","iopub.status.idle":"2024-10-03T06:53:17.925828Z","shell.execute_reply.started":"2024-10-03T06:53:17.917836Z","shell.execute_reply":"2024-10-03T06:53:17.92456Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X_train.head()","metadata":{"id":"AbBLyjl98ckf","outputId":"e60a98d5-72a5-4f9c-d890-fd8c1a083aa4","execution":{"iopub.status.busy":"2024-10-03T06:53:17.927312Z","iopub.execute_input":"2024-10-03T06:53:17.927654Z","iopub.status.idle":"2024-10-03T06:53:17.946804Z","shell.execute_reply.started":"2024-10-03T06:53:17.927611Z","shell.execute_reply":"2024-10-03T06:53:17.945652Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"Y_train.head()","metadata":{"id":"4b-NSIDd8fH3","outputId":"81b8f3e9-7198-45e8-edf6-28335b59c81a","execution":{"iopub.status.busy":"2024-10-03T06:53:17.948096Z","iopub.execute_input":"2024-10-03T06:53:17.948493Z","iopub.status.idle":"2024-10-03T06:53:17.959412Z","shell.execute_reply.started":"2024-10-03T06:53:17.948444Z","shell.execute_reply":"2024-10-03T06:53:17.958108Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X_test.head()","metadata":{"id":"-csZh8L_-4Zr","outputId":"841023b4-9137-4fb9-d010-0893e23d74a2","execution":{"iopub.status.busy":"2024-10-03T06:53:17.960733Z","iopub.execute_input":"2024-10-03T06:53:17.961074Z","iopub.status.idle":"2024-10-03T06:53:17.979193Z","shell.execute_reply.started":"2024-10-03T06:53:17.96104Z","shell.execute_reply":"2024-10-03T06:53:17.978065Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"Y_test.head()","metadata":{"id":"56Glh1j9-6Xg","outputId":"c5274c7b-d1c6-473b-dc34-910f6d12eca2","execution":{"iopub.status.busy":"2024-10-03T06:53:17.983829Z","iopub.execute_input":"2024-10-03T06:53:17.984239Z","iopub.status.idle":"2024-10-03T06:53:17.992413Z","shell.execute_reply.started":"2024-10-03T06:53:17.984198Z","shell.execute_reply":"2024-10-03T06:53:17.991085Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"classifier=svm.SVC(kernel='linear')","metadata":{"id":"MRHkLO5c-8Fo","execution":{"iopub.status.busy":"2024-10-03T06:53:17.993657Z","iopub.execute_input":"2024-10-03T06:53:17.994019Z","iopub.status.idle":"2024-10-03T06:53:18.002161Z","shell.execute_reply.started":"2024-10-03T06:53:17.993984Z","shell.execute_reply":"2024-10-03T06:53:18.000937Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"classifier.fit(X_train,Y_train)","metadata":{"id":"zMPHPi4u--6c","outputId":"d4b3825b-4132-428f-8471-7e8299189643","execution":{"iopub.status.busy":"2024-10-03T06:53:18.003354Z","iopub.execute_input":"2024-10-03T06:53:18.003818Z","iopub.status.idle":"2024-10-03T06:53:19.527306Z","shell.execute_reply.started":"2024-10-03T06:53:18.003775Z","shell.execute_reply":"2024-10-03T06:53:19.526088Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X_train_prediction=classifier.predict(X_train)\ntraining_dataset_accuracy= accuracy_score(X_train_prediction,Y_train)","metadata":{"id":"h8iwW7wW_AvN","execution":{"iopub.status.busy":"2024-10-03T06:53:19.528611Z","iopub.execute_input":"2024-10-03T06:53:19.528984Z","iopub.status.idle":"2024-10-03T06:53:19.541518Z","shell.execute_reply.started":"2024-10-03T06:53:19.528947Z","shell.execute_reply":"2024-10-03T06:53:19.540243Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print('Accuracy for training dataset achived: ',training_dataset_accuracy*100)","metadata":{"id":"FjRjEIGW_IKv","outputId":"d32713fb-b41c-4a3f-9736-d045a8fbbb5d","execution":{"iopub.status.busy":"2024-10-03T06:53:19.543117Z","iopub.execute_input":"2024-10-03T06:53:19.543598Z","iopub.status.idle":"2024-10-03T06:53:19.549628Z","shell.execute_reply.started":"2024-10-03T06:53:19.543506Z","shell.execute_reply":"2024-10-03T06:53:19.548553Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X_test_prediction=classifier.predict(X_test)\ntest_data_accuracy = accuracy_score(X_test_prediction,Y_test)","metadata":{"id":"OumzvTG0_Kvm","execution":{"iopub.status.busy":"2024-10-03T06:53:19.550758Z","iopub.execute_input":"2024-10-03T06:53:19.551091Z","iopub.status.idle":"2024-10-03T06:53:19.575974Z","shell.execute_reply.started":"2024-10-03T06:53:19.551051Z","shell.execute_reply":"2024-10-03T06:53:19.574923Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print('Accuracy for test dataset achived: ',test_data_accuracy*100)","metadata":{"id":"CrH8Oy5t_Qqe","outputId":"42bf02e2-3d57-4e4e-b4d0-d33c05a9239c","execution":{"iopub.status.busy":"2024-10-03T06:53:19.577548Z","iopub.execute_input":"2024-10-03T06:53:19.577893Z","iopub.status.idle":"2024-10-03T06:53:19.583159Z","shell.execute_reply.started":"2024-10-03T06:53:19.577858Z","shell.execute_reply":"2024-10-03T06:53:19.582003Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"input_data=(0,1,1,1,0,1,0,3,103,82,60,106,95,27,0.94,13)\ninput_data_as_numpy_array = np.asarray(input_data)\ninput_data_reshaped = input_data_as_numpy_array.reshape(1,-1)\nprediction = classifier.predict(input_data_reshaped)\nprint(prediction)\nif(prediction[0]==0):\n    print('Normal')\nelif(prediction[0]==1):\n  print('Mild')\nelif(prediction[0]==2):\n  print('Severe')\nelif(prediction[0]==3):\n  print('Chronic')","metadata":{"id":"BXjEVaDi_T6A","outputId":"6308ff1d-3126-402c-86d1-1001d474344f","execution":{"iopub.status.busy":"2024-10-03T06:53:19.584729Z","iopub.execute_input":"2024-10-03T06:53:19.585202Z","iopub.status.idle":"2024-10-03T06:53:19.598458Z","shell.execute_reply.started":"2024-10-03T06:53:19.585156Z","shell.execute_reply":"2024-10-03T06:53:19.597328Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.metrics import confusion_matrix\n\n# Predict on the test data\nX_test_prediction = classifier.predict(X_test)\n\n# Generate the confusion matrix\nconf_matrix = confusion_matrix(Y_test, X_test_prediction)\nprint(\"Confusion Matrix:\\n\", conf_matrix)\n\n","metadata":{"id":"wdxMXIM9AXg5","outputId":"08597503-ff89-4bc6-d7fb-3378a88ed133","execution":{"iopub.status.busy":"2024-10-03T06:53:19.599732Z","iopub.execute_input":"2024-10-03T06:53:19.600099Z","iopub.status.idle":"2024-10-03T06:53:19.628621Z","shell.execute_reply.started":"2024-10-03T06:53:19.600063Z","shell.execute_reply":"2024-10-03T06:53:19.627453Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.metrics import classification_report\n\n# Print precision, recall, f1-score for each class\nprint(\"Classification Report:\\n\", classification_report(Y_test, X_test_prediction))\n","metadata":{"id":"resBEkffm1Dg","outputId":"e5eeff9d-2493-40e4-c80c-deafd9750408","execution":{"iopub.status.busy":"2024-10-03T06:53:19.629819Z","iopub.execute_input":"2024-10-03T06:53:19.630179Z","iopub.status.idle":"2024-10-03T06:53:19.650458Z","shell.execute_reply.started":"2024-10-03T06:53:19.630143Z","shell.execute_reply":"2024-10-03T06:53:19.649425Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.metrics import matthews_corrcoef\n\nmcc = matthews_corrcoef(Y_test, X_test_prediction)\nprint(\"Matthews Correlation Coefficient: {:.2f}\".format(mcc))\n","metadata":{"id":"Es_EJk9om7_f","outputId":"0b28ecc4-14bb-4c7c-8962-c277ca5237ef","execution":{"iopub.status.busy":"2024-10-03T06:53:19.651734Z","iopub.execute_input":"2024-10-03T06:53:19.65207Z","iopub.status.idle":"2024-10-03T06:53:19.663217Z","shell.execute_reply.started":"2024-10-03T06:53:19.652035Z","shell.execute_reply":"2024-10-03T06:53:19.662028Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.metrics import balanced_accuracy_score\n\nbalanced_acc = balanced_accuracy_score(Y_test, X_test_prediction)\nprint(\"Balanced Accuracy: {:.2f}\".format(balanced_acc))\n","metadata":{"id":"N4cxxZ-anqHX","outputId":"8a45c36f-7e8e-441d-90fc-8f8ab2b3b1b0","execution":{"iopub.status.busy":"2024-10-03T06:53:19.664707Z","iopub.execute_input":"2024-10-03T06:53:19.665118Z","iopub.status.idle":"2024-10-03T06:53:19.673388Z","shell.execute_reply.started":"2024-10-03T06:53:19.665081Z","shell.execute_reply":"2024-10-03T06:53:19.672331Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.model_selection import cross_val_score\n\n# Perform 5-fold cross-validation\ncv_scores = cross_val_score(classifier, X, Y, cv=5)\n\n# Print the average accuracy\nprint(\"Average cross-validation accuracy: {:.2f}%\".format(cv_scores.mean() * 100))\n","metadata":{"id":"ouROpRbanyqS","execution":{"iopub.status.busy":"2024-10-03T06:53:19.674777Z","iopub.execute_input":"2024-10-03T06:53:19.675316Z","iopub.status.idle":"2024-10-03T06:53:56.811788Z","shell.execute_reply.started":"2024-10-03T06:53:19.675275Z","shell.execute_reply":"2024-10-03T06:53:56.810745Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.svm import SVC\n\n# Add regularization (C=1.0) to reduce overfitting\nclassifier = SVC(kernel='linear', C=1.0, class_weight='balanced', probability=True)\n","metadata":{"execution":{"iopub.status.busy":"2024-10-03T06:53:56.812959Z","iopub.execute_input":"2024-10-03T06:53:56.813298Z","iopub.status.idle":"2024-10-03T06:53:56.818493Z","shell.execute_reply.started":"2024-10-03T06:53:56.813263Z","shell.execute_reply":"2024-10-03T06:53:56.81732Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.model_selection import cross_val_score\n\n# Perform 5-fold cross-validation\ncv_scores = cross_val_score(classifier, X, Y, cv=5)\n\n# Print the average accuracy\nprint(\"Average cross-validation accuracy: {:.2f}%\".format(cv_scores.mean() * 100))","metadata":{"execution":{"iopub.status.busy":"2024-10-03T06:53:56.819777Z","iopub.execute_input":"2024-10-03T06:53:56.820162Z","iopub.status.idle":"2024-10-03T06:57:35.993792Z","shell.execute_reply.started":"2024-10-03T06:53:56.820101Z","shell.execute_reply":"2024-10-03T06:57:35.99249Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{},"outputs":[],"execution_count":null}]}