fix: unwanted repos removed

This commit is contained in:
Advaita Saha 2022-10-09 02:45:42 +05:30
parent 1940244d1f
commit 11db70ff89
5 changed files with 109 additions and 102 deletions

View File

@ -3,8 +3,8 @@
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
"colab_type": "text",
"id": "view-in-github"
},
"source": [
"<a href=\"https://colab.research.google.com/github/riyajaiswal25/MLProjects/blob/main/DigitRecognitionusingRandomForestClassifier.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
@ -62,11 +62,7 @@
},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"<IPython.core.display.HTML object>"
],
"text/html": [
"\n",
" <input type=\"file\" id=\"files-7634f8da-a56b-480e-a6d2-1cc2533a486a\" name=\"files[]\" multiple disabled\n",
@ -251,13 +247,17 @@
"};\n",
"})(self);\n",
"</script> "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {}
"metadata": {},
"output_type": "display_data"
},
{
"output_type": "stream",
"name": "stdout",
"output_type": "stream",
"text": [
"Saving train[1].csv to train[1].csv\n"
]
@ -270,39 +270,36 @@
},
{
"cell_type": "markdown",
"source": [
"**Load Dataset**"
],
"metadata": {
"id": "TJRApm0w0Dct"
}
},
"source": [
"**Load Dataset**"
]
},
{
"cell_type": "code",
"source": [
"dataset = pd.read_csv('train.csv')"
],
"execution_count": 4,
"metadata": {
"id": "GyOvJOoR0Lhq"
},
"execution_count": 4,
"outputs": []
"outputs": [],
"source": [
"dataset = pd.read_csv('train.csv')"
]
},
{
"cell_type": "markdown",
"source": [
"**Summarize dataset**"
],
"metadata": {
"id": "0txmydWY0ZEH"
}
},
"source": [
"**Summarize dataset**"
]
},
{
"cell_type": "code",
"source": [
"print(dataset.shape)\n",
"print(dataset.head(5))"
],
"execution_count": 5,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@ -310,11 +307,10 @@
"id": "AW-9ITV10cIY",
"outputId": "dce2cb6d-2bdb-41e5-de9e-baf122900140"
},
"execution_count": 5,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"output_type": "stream",
"text": [
"(42000, 785)\n",
" label pixel0 pixel1 pixel2 pixel3 pixel4 pixel5 pixel6 pixel7 \\\n",
@ -341,24 +337,24 @@
"[5 rows x 785 columns]\n"
]
}
],
"source": [
"print(dataset.shape)\n",
"print(dataset.head(5))"
]
},
{
"cell_type": "markdown",
"source": [
"**Segregate Dataset into X(Input/Independent Variable) & Y(Output/Dependent Variable)**"
],
"metadata": {
"id": "QUh5BKq20viv"
}
},
"source": [
"**Segregate Dataset into X(Input/Independent Variable) & Y(Output/Dependent Variable)**"
]
},
{
"cell_type": "code",
"source": [
"X = dataset.iloc[:,1:]\n",
"print(X)\n",
"print(X.shape)"
],
"execution_count": 6,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@ -366,11 +362,10 @@
"id": "OP2TX3iX09ND",
"outputId": "9c8f44e2-a503-4acf-8978-f6576706e402"
},
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"output_type": "stream",
"text": [
" pixel0 pixel1 pixel2 pixel3 pixel4 pixel5 pixel6 pixel7 pixel8 \\\n",
"0 0 0 0 0 0 0 0 0 0 \n",
@ -415,15 +410,16 @@
"(42000, 784)\n"
]
}
],
"source": [
"X = dataset.iloc[:,1:]\n",
"print(X)\n",
"print(X.shape)"
]
},
{
"cell_type": "code",
"source": [
"Y = dataset.iloc[:,0]\n",
"print(Y)\n",
"print(Y.shape)"
],
"execution_count": 7,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@ -431,11 +427,10 @@
"id": "2RuBl7671GH4",
"outputId": "96d6afef-f2ed-420f-d95c-826a287fa8dd"
},
"execution_count": 7,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"output_type": "stream",
"text": [
"0 1\n",
"1 0\n",
@ -452,45 +447,46 @@
"(42000,)\n"
]
}
],
"source": [
"Y = dataset.iloc[:,0]\n",
"print(Y)\n",
"print(Y.shape)"
]
},
{
"cell_type": "markdown",
"source": [
"**Splitting Dataset into Test and Train**"
],
"metadata": {
"id": "o1j-AGZd1OQV"
}
},
"source": [
"**Splitting Dataset into Test and Train**"
]
},
{
"cell_type": "code",
"source": [
"from sklearn.model_selection import train_test_split\n",
"X_train, X_test, y_train, y_test = train_test_split(X,Y, test_size = 0.25, random_state = 0)"
],
"execution_count": 8,
"metadata": {
"id": "U_c_R4HA1SeZ"
},
"execution_count": 8,
"outputs": []
"outputs": [],
"source": [
"from sklearn.model_selection import train_test_split\n",
"X_train, X_test, y_train, y_test = train_test_split(X,Y, test_size = 0.25, random_state = 0)"
]
},
{
"cell_type": "markdown",
"source": [
"**Training**"
],
"metadata": {
"id": "Gf6EgvAc1vjh"
}
},
"source": [
"**Training**"
]
},
{
"cell_type": "code",
"source": [
"from sklearn.ensemble import RandomForestClassifier\n",
"model = RandomForestClassifier()\n",
"model.fit(X_train, y_train)"
],
"execution_count": 9,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@ -498,46 +494,47 @@
"id": "RS4TAnDh1yUU",
"outputId": "4803259d-f3a1-461f-d3d0-939bc4495a64"
},
"execution_count": 9,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"RandomForestClassifier()"
]
},
"execution_count": 9,
"metadata": {},
"execution_count": 9
"output_type": "execute_result"
}
],
"source": [
"from sklearn.ensemble import RandomForestClassifier\n",
"model = RandomForestClassifier()\n",
"model.fit(X_train, y_train)"
]
},
{
"cell_type": "code",
"source": [
"y_pred = model.predict(X_test)"
],
"execution_count": 10,
"metadata": {
"id": "SljeEEbs2JFT"
},
"execution_count": 10,
"outputs": []
"outputs": [],
"source": [
"y_pred = model.predict(X_test)"
]
},
{
"cell_type": "markdown",
"source": [
"**Model Accuracy**"
],
"metadata": {
"id": "4XEvHILm2OF-"
}
},
"source": [
"**Model Accuracy**"
]
},
{
"cell_type": "code",
"source": [
"from sklearn.metrics import accuracy_score\n",
"print(\"Accuracy of the Model: {0}%\".format(accuracy_score(y_test, y_pred)*100))"
],
"execution_count": 11,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@ -545,26 +542,23 @@
"id": "sHEVc1Qq2Rqy",
"outputId": "06be6e32-1ba4-4035-eafb-3b3c2023abd6"
},
"execution_count": 11,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"output_type": "stream",
"text": [
"Accuracy of the Model: 96.31428571428572%\n"
]
}
],
"source": [
"from sklearn.metrics import accuracy_score\n",
"print(\"Accuracy of the Model: {0}%\".format(accuracy_score(y_test, y_pred)*100))"
]
},
{
"cell_type": "code",
"source": [
"import matplotlib.pyplot as plt\n",
"index=10\n",
"print(\"Predicted \" +str(model.predict(X_test)[index]))\n",
"plt.axis('off')\n",
"plt.imshow(X_test.iloc[index].values.reshape((28,28)),cmap='gray')"
],
"execution_count": 13,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
@ -573,54 +567,67 @@
"id": "iymJ1Zpj20gk",
"outputId": "ae21ce24-b957-4a30-8f04-ec5c77dd5a53"
},
"execution_count": 13,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"output_type": "stream",
"text": [
"Predicted 7\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7ff128cbac90>"
]
},
"execution_count": 13,
"metadata": {},
"execution_count": 13
"output_type": "execute_result"
},
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAOcAAADnCAYAAADl9EEgAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAF8UlEQVR4nO3dPWtUaxuG4XdJ4kelJqJVEAuriAja2NhaWSmxs7Ky1UoJCAEhRdKKhWBjIdqJaUQEsRFELNQ/IDaCgqIEP3DtOuyse9zzTjLXTI6j9GKShXLuB/bDzDRt2/4PyLNt2A8ArE+cEEqcEEqcEEqcEGqiGpum8b9yYYO1bdus9+dOTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgg1MewHGEcLCwvl/vPnz85tdXW1fO21a9fKfc+ePeX+58+fch+mGzdudG7z8/Ob+CQZnJwQSpwQSpwQSpwQSpwQSpwQSpwQqmnbtntsmu5xjO3evbvcFxcXy/3ChQvlvn379v/8TH+raZpyr/69h+3Nmzed27FjxzbxSTZX27br/qM5OSGUOCGUOCGUOCGUOCGUOCGUOCHUlrznPHXqVLnfvn273A8dOjTIxxmoUb7n/P79e+fW6+55lLnnhBEjTgglTgglTgglTgglTgglTgg1tp9be+LEic7t0aNH5Wt37do16McZmF6fa/vt27dy/3/uObdtq/9bvm/fvr5/Nv/m5IRQ4oRQ4oRQ4oRQ4oRQ4oRQ4oRQY3vPWX3OafI95srKSrlfv3693F+9ejXAp1lr586d5f748eNyP3nyZLlPTk52brOzs+Vr3759W+6jyMkJocQJocQJocQJocQJocQJocb2KmVubm5ov/v379/lfuvWrc5tfn6+fO3Xr1/7eqZR8OvXr85tHK9KenFyQihxQihxQihxQihxQihxQihxQqixvec8cODAhv3sXh9PefHixXK/d+/eIB9n00xPT5d7r7eE9VLdc25FTk4IJU4IJU4IJU4IJU4IJU4IJU4INbb3nA8ePOjcpqamytfevXu33JeXl8v948eP5T6qqr/TQTh37tyG/vxR4+SEUOKEUOKEUOKEUOKEUOKEUOKEUE3btt1j03SPI2xmZqbc379/v0lPkufgwYOd27t378rX7tixo9w/fPhQ7kePHu3cvnz5Ur52lLVt26z3505OCCVOCCVOCCVOCCVOCCVOCCVOCDW27+esbOV7zF6uXLnSufW6x+zl2bNn5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xs7Ky1UoJCAEhRdKKhWBjIdqJaUQEsRFELNQ/IDaCgqIEP3DtOuyse9zzTjLXTI6j9GKShXLuB/bDzDRt2/4PyLNt2A8ArE+cEEqcEEqcEEqcEGqiGpum8b9yYYO1bdus9+dOTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgglTgg1MewHGEcLCwvl/vPnz85tdXW1fO21a9fKfc+ePeX+58+fch+mGzdudG7z8/Ob+CQZnJwQSpwQSpwQSpwQSpwQSpwQSpwQqmnbtntsmu5xjO3evbvcFxcXy/3ChQvlvn379v/8TH+raZpyr/69h+3Nmzed27FjxzbxSTZX27br/qM5OSGUOCGUOCGUOCGUOCGUOCGUOCHUlrznPHXqVLnfvn273A8dOjTIxxmoUb7n/P79e+fW6+55lLnnhBEjTgglTgglTgglTgglTgglTgg1tp9be+LEic7t0aNH5Wt37do16McZmF6fa/vt27dy/3/uObdtq/9bvm/fvr5/Nv/m5IRQ4oRQ4oRQ4oRQ4oRQ4oRQ4oRQY3vPWX3OafI95srKSrlfv3693F+9ejXAp1lr586d5f748eNyP3nyZLlPTk52brOzs+Vr3759W+6jyMkJocQJocQJocQJocQJocQJocb2KmVubm5ov/v379/lfuvWrc5tfn6+fO3Xr1/7eqZR8OvXr85tHK9KenFyQihxQihxQihxQihxQihxQihxQqixvec8cODAhv3sXh9PefHixXK/d+/eIB9n00xPT5d7r7eE9VLdc25FTk4IJU4IJU4IJU4IJU4IJU4IJU4INbb3nA8ePOjcpqamytfevXu33JeXl8v948eP5T6qqr/TQTh37tyG/vxR4+SEUOKEUOKEUOKEUOKEUOKEUOKEUE3btt1j03SPI2xmZqbc379/v0lPkufgwYOd27t378rX7tixo9w/fPhQ7kePHu3cvnz5Ur52lLVt26z3505OCCVOCCVOCCVOCCVOCCVOCCVOCDW27+esbOV7zF6uXLnSufW6x+zl2bNn5T7Od5n9cHJCKHFCKHFCKHFCKHFCKHFCqC15lTLOJicny31ubq7cL1261Pfv/vHjR7k/efKk75+9FTk5IZQ4IZQ4IZQ4IZQ4IZQ4IZQ4IZR7zjHT655yaWmp3KuPSu1lYWGh3O/cudP3z96KnJwQSpwQSpwQSpwQSpwQSpwQSpwQakt+BeAoO3LkSLk/ffq03Pfu3dv37/78+XO5Hz58uNx99OX6fAUgjBhxQihxQihxQihxQihxQihxQijv5wxz/Pjxcl9ZWSn3qampcu/1fs3V1dXO7fz58+Vr3WMOlpMTQokTQokTQokTQokTQokTQrlKGYKZmZnO7eHDh+Vrp6enB/04aywvL3duvd6OxmA5OSGUOCGUOCGUOCGUOCGUOCGUOCGUe84NMDs7W+5Xr17t3Pbv3z/ox1nj5cuX5b64uLihv5+/5+SEUOKEUOKEUOKEUOKEUOKEUOKEUL4CsA8TE/X18P3798v9zJkzg3ycNT59+lTup0+fLvfXr18P8nH4C74CEEaMOCGUOCGUOCGUOCGUOCGUOCGU93P24ebNm+U+zHvMy5cvl7t7zNHh5IRQ4oRQ4oRQ4oRQ4oRQ4oRQ4oRQ7jn70OtzaTfS2bNny/358+eb9CRsNCcnhBInhBInhBInhBInhBInhHKVEmZpaancX7x4sUlPwrA5OSGUOCGUOCGUOCGUOCGUOCGUOCGUrwCEIfMVgDBixAmhxAmhxAmhxAmhxAmhxAmhyntOYHicnBBKnBBKnBBKnBBKnBBKnBDqH2Wm9vKr3NQPAAAAAElFTkSuQmCC\n"
]
},
"metadata": {
"needs_background": "light"
}
},
"output_type": "display_data"
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"index=10\n",
"print(\"Predicted \" +str(model.predict(X_test)[index]))\n",
"plt.axis('off')\n",
"plt.imshow(X_test.iloc[index].values.reshape((28,28)),cmap='gray')"
]
}
],
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyOBzEe2vR1rQh4B8yWT0mhr",
"include_colab_link": true
"include_colab_link": true,
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.8.9 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"name": "python",
"version": "3.8.9"
},
"vscode": {
"interpreter": {
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
}
}
},
"nbformat": 4,
"nbformat_minor": 0
}
}