zahra пре 1 година
родитељ
комит
b8f1231b2d
2 измењених фајлова са 189 додато и 33 уклоњено
  1. 96 0
      python/Zahra-Test-Modification.ipynb
  2. 93 33
      python/Zahra-Test.ipynb

+ 96 - 0
python/Zahra-Test-Modification.ipynb

@@ -0,0 +1,96 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 14,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "import numpy as np \n",
+    "import pandas as pd\n",
+    "import matplotlib.pyplot as plt\n",
+    "from sklearn.feature_selection import SelectKBest\n",
+    "from sklearn.feature_selection import chi2\n",
+    "from sklearn.preprocessing import StandardScaler \n",
+    "from sklearn.linear_model import LogisticRegression\n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 15,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "# Load Breast Cancer dataset\n",
+    "url = \"https://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/wdbc.data\"\n",
+    "\n",
+    "# Define column names\n",
+    "columns = [\"ID\", \"Diagnosis\", \"Radius_mean\", \"Texture_mean\", \"Perimeter_mean\", \"Area_mean\",\n",
+    "           \"Smoothness_mean\", \"Compactness_mean\", \"Concavity_mean\", \"Concave_points_mean\",\n",
+    "           \"Symmetry_mean\", \"Fractal_dimension_mean\", \"Radius_se\", \"Texture_se\", \n",
+    "           \"Perimeter_se\", \"Area_se\", \"Smoothness_se\", \"Compactness_se\", \"Concavity_se\", \n",
+    "           \"Concave_points_se\", \"Symmetry_se\", \"Fractal_dimension_se\", \"Radius_worst\",\n",
+    "           \"Texture_worst\", \"Perimeter_worst\", \"Area_worst\", \"Smoothness_worst\", \n",
+    "           \"Compactness_worst\", \"Concavity_worst\", \"Concave_points_worst\", \n",
+    "           \"Symmetry_worst\", \"Fractal_dimension_worst\"]\n",
+    "\n",
+    "# Load data\n",
+    "df=pd.read_csv(url,names=columns)\n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 16,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "# Drop the 'ID' column and convert diagnosis to numeric (Malignant = 1, Benign = 0)\n",
+    "df.drop(columns=[\"ID\"], inplace=True)\n",
+    "df[\"Diagnosis\"] = df[\"Diagnosis\"].map({\"M\": 1, \"B\": 0})"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 17,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "# Separate features and target\n",
+    "X = df.drop(columns=[\"Diagnosis\"])\n",
+    "y = df[\"Diagnosis\"]"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 18,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "# Select the best 5 features using the chi-square test\n",
+    "selector = SelectKBest(chi2, k=5)  # Adjust k to select the number of features you want\n",
+    "X_new = selector.fit_transform(X, y)"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "base",
+   "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.12.7"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}

Разлика између датотеке није приказан због своје велике величине
+ 93 - 33
python/Zahra-Test.ipynb


Неке датотеке нису приказане због велике количине промена