diff --git a/Applications/ML Algorithms/KNN.ipynb b/Applications/ML Algorithms/KNN.ipynb deleted file mode 100644 index abbfd45..0000000 --- a/Applications/ML Algorithms/KNN.ipynb +++ /dev/null @@ -1 +0,0 @@ -{"cells":[{"cell_type":"markdown","metadata":{"id":"RHxCzcMw6yo1"},"source":["## What is K Nearest Neighbour ?"]},{"cell_type":"markdown","metadata":{"id":"itveBW6M69YO"},"source":["K-Nearest Neighbors (K-NN) is a supervised machine learning algorithm used for classification and regression tasks. It's a simple and intuitive algorithm that can be used for both classification and regression tasks."]},{"cell_type":"markdown","metadata":{"id":"NkX1uGxl7Q9N"},"source":["### Choosing K:\n","\n","One crucial hyperparameter in K-NN is the value of K. The choice of K can significantly impact the algorithm's performance. A smaller K value makes the algorithm more sensitive to noise in the data, potentially leading to overfitting, while a larger K value can make the decision boundary smoother but may result in underfitting."]},{"cell_type":"markdown","metadata":{"id":"d5jQMxtl86-A"},"source":["## When to use KNN ?"]},{"cell_type":"markdown","metadata":{"id":"Y8TXq9fS9DB4"},"source":["K-Nearest Neighbors (K-NN) is a versatile algorithm that can be useful in certain situations. Here are some scenarios in which you might consider using K-NN:\n","\n","* Multi-Class Classification: K-NN can also be applied to multi-class classification problems, where you need to classify data points into more than two classes. However, the choice of K and distance metric becomes more critical in these cases.\n","\n","* Regression: K-NN can be used for regression tasks when you need to predict a continuous target variable. It calculates the average (or weighted average) of the target values of the K nearest neighbors to make predictions.\n","\n","* Feature Engineering: K-NN can help identify important features in your dataset. By examining which features are most influential in determining the nearest neighbors, you can gain insights into the importance of various features."]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":463},"id":"6QjqxoV0-K3Y","outputId":"8d55e697-19f2-4643-cf31-ed37c7e10b8f"},"outputs":[{"data":{"text/html":[""],"text/plain":[""]},"execution_count":3,"metadata":{},"output_type":"execute_result"}],"source":["from IPython.display import Image\n","Image(url='https://miro.medium.com/v2/resize:fit:828/1*n9v1xsBi0bek98rqBnWGEg.gif')"]},{"cell_type":"markdown","metadata":{},"source":["## Real-life application of KNN:\n","\n","KNN can be used to predict customer churn in a business setting. For example, a company could use KNN to identify customers who are likely to cancel their subscription or stop using their product. The company could then target these customers with special offers or promotions in an attempt to retain them."]},{"cell_type":"code","execution_count":1,"metadata":{},"outputs":[{"data":{"image/png":"iVBORw0KGgoAAAANSUhEUgAAAjIAAAGwCAYAAACzXI8XAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAxLElEQVR4nO3df3RU9Z3/8dckIT9JhkAIJpCQH7CAgAMIyg8VoxRqldXu2q4tXal2da24StJjBVtxqWLEs7KsoFi0i9IFq7vrL6y6XyVVRIkgkhyiEpCgpCESgpAQJr8mc79/wIwJSSAhM3Pnzjwf58wpuXMH3hArLz+ve+/HZhiGIQAAAAuKMHsAAACA80WQAQAAlkWQAQAAlkWQAQAAlkWQAQAAlkWQAQAAlkWQAQAAlhVl9gD+5na7dejQISUmJspms5k9DgAA6AHDMHTixAmlp6crIqL7dZeQDzKHDh1SRkaG2WMAAIDzUFlZqWHDhnX7fsgHmcTEREnSiv9br7iEeJOnAQAAPdF40qmCOTd7/x7vTsgHGU+dFJcQr7j+BBkAAKzkXJeFcLEvAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAACwLIIMAAAhzNXWpqMn6lTfeNLsUfwiyuwBAACA7zW3tmjTpx+o6LNP5GxpkiQNT0nT3158uS7OHmPydL5j6orMli1bNHfuXKWnp8tms+nVV1/t8L5hGFqyZInS0tIUFxenWbNmad++feYMCwCARTS3tmr5pvX6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vGLX6ilpeWsQcZms8kwjA7HurqY1xOqPPNI0jPPPKNLL720w3mea3oAWAtBBoDfTJo0SeXl5V2GHEnauXOn3G63Hn/8cUVEnLr34KWXXupwTnR0tNra2jp9dvDgwaqurvZ+vW/fPjmdzrPOM2TIEKWnp6uiokLz5s3r7W8HQBAiyADwmyVLlui6665TZmambrzxRkVERKi0tFRlZWV6+OGHNWLECLW2tmrVqlWaO3euPvzwQz399NMdfo6srCw1NDRo8+bNcjgcio+PV3x8vK666iqtXr1a06ZNU1tbm+677z7169fvnDMtXbpUd999t+x2u77//e+rublZn3zyiY4dO6aCgoIuP9PQ0NDhuTgHDhxQSUmJBg4cqMzMzL79IQHoG7Mv0gFgbfPnzzeuv/76bt9/++23jenTpxtxcXFGUlKScckllxhr1671vr9ixQojLS3NiIuLM+bMmWOsX7/ekGQcO3bMe84dd9xhDBo0yJBkPPjgg4ZhGEZVVZUxe/ZsIyEhwRg5cqTx5ptvdnmx765duzrNtGHDBmPChAlGdHS0kZycbFxxxRXGyy+/3O3v4S9/+YshqdNr/vz5vfiTAuAPNsM4o2QGAACwCB6IBwAALIsgAwAALIsgAwAALIsgAwAALIsgAwAALIsgAwAALIsgAwAALIsgAwAALIsgAwAALIsgAwAALIsgAwAALOv/A2F5CmUvjwCNAAAAAElFTkSuQmCC","text/plain":["
"]},"metadata":{},"output_type":"display_data"}],"source":["import numpy as np\n","from sklearn.neighbors import KNeighborsClassifier\n","import matplotlib.pyplot as plt\n","\n","# Load and prepare the dataset\n","X = np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]])\n","y = np.array([0, 0, 1, 1, 1])\n","\n","# Create the KNN model\n","knn = KNeighborsClassifier(n_neighbors=3)\n","\n","# Train the model\n","knn.fit(X, y)\n","\n","# Create a meshgrid for decision boundaries\n","x_min, x_max = X[:, 0].min() - 1, X[:, 0].max() + 1\n","y_min, y_max = X[:, 1].min() - 1, X[:, 1].max() + 1\n","xx, yy = np.meshgrid(np.arange(x_min, x_max, 0.1), np.arange(y_min, y_max, 0.1))\n","\n","# Predict and plot the decision boundaries\n","Z = knn.predict(np.c_[xx.ravel(), yy.ravel()])\n","Z = Z.reshape(xx.shape)\n","plt.contourf(xx, yy, Z, cmap='RdYlGn', alpha=0.4)\n","\n","# Plot the training data\n","plt.scatter(X[:, 0], X[:, 1], c=y, cmap='RdYlGn')\n","\n","# Label the axes\n","plt.xlabel('Feature 1')\n","plt.ylabel('Feature 2')\n","\n","# Show the plot\n","plt.show()"]},{"cell_type":"markdown","metadata":{},"source":["This code will create a scatter plot of the training data, with the different classes represented by different colors. The KNN decision boundaries will be overlaid on the plot as a shaded region."]},{"cell_type":"markdown","metadata":{},"source":["#### As you can see, the KNN model has learned to distinguish between the two classes of data points. The shaded region represents the area where the model predicts that a new data point is likely to belong to the red class.\n","\n","KNN is a simple but powerful machine learning algorithm that can be used for a variety of real-world tasks. It is particularly well-suited for classification problems where labeled data is scarce."]}],"metadata":{"colab":{"provenance":[]},"kernelspec":{"display_name":"Python 3","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.4"}},"nbformat":4,"nbformat_minor":0}