From 6046141353dbb20714f56e9d83e9e7e8f40e32e7 Mon Sep 17 00:00:00 2001 From: Stormbreaker20 Date: Wed, 4 Oct 2023 21:33:37 +0530 Subject: [PATCH] Updated the Structure Added Ml, Application folder with Computational Algorithms Added Application of KNN --- Applications/ML Algorithms/KNN.ipynb | 1 + .../Applications/Ml Algorithms/Iris.csv | 151 ----- .../Applications/Ml Algorithms/PCA.ipynb | 620 ------------------ .../DSA Algorithms => Heaps}/heapify.cpp | 0 Ml Algorithms/KNN/KNN.ipynb | 354 ++++++++++ Ml Algorithms/KNN/Social_Network_Ads.csv | 401 +++++++++++ 6 files changed, 756 insertions(+), 771 deletions(-) create mode 100644 Applications/ML Algorithms/KNN.ipynb delete mode 100644 Computational Algorithms/Applications/Ml Algorithms/Iris.csv delete mode 100644 Computational Algorithms/Applications/Ml Algorithms/PCA.ipynb rename Computational Algorithms/{Applications/DSA Algorithms => Heaps}/heapify.cpp (100%) create mode 100644 Ml Algorithms/KNN/KNN.ipynb create mode 100644 Ml Algorithms/KNN/Social_Network_Ads.csv diff --git a/Applications/ML Algorithms/KNN.ipynb b/Applications/ML Algorithms/KNN.ipynb new file mode 100644 index 0000000..abbfd45 --- /dev/null +++ b/Applications/ML Algorithms/KNN.ipynb @@ -0,0 +1 @@ +{"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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5ptvdnmx765duzrNtGHDBmPChAlGdHS0kZycbFxxxRXGyy+/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} diff --git a/Computational Algorithms/Applications/Ml Algorithms/Iris.csv b/Computational Algorithms/Applications/Ml Algorithms/Iris.csv deleted file mode 100644 index 79bc2c5..0000000 --- a/Computational Algorithms/Applications/Ml Algorithms/Iris.csv +++ /dev/null @@ -1,151 +0,0 @@ -SepalLengthCm,SepalWidthCm,PetalLengthCm,PetalWidthCm,Species -5.1,3.5,1.4,0.2,Iris-setosa -4.9,3,1.4,0.2,Iris-setosa -4.7,3.2,1.3,0.2,Iris-setosa -4.6,3.1,1.5,0.2,Iris-setosa -5,3.6,1.4,0.2,Iris-setosa -5.4,3.9,1.7,0.4,Iris-setosa -4.6,3.4,1.4,0.3,Iris-setosa -5,3.4,1.5,0.2,Iris-setosa -4.4,2.9,1.4,0.2,Iris-setosa -4.9,3.1,1.5,0.1,Iris-setosa -5.4,3.7,1.5,0.2,Iris-setosa -4.8,3.4,1.6,0.2,Iris-setosa -4.8,3,1.4,0.1,Iris-setosa -4.3,3,1.1,0.1,Iris-setosa -5.8,4,1.2,0.2,Iris-setosa -5.7,4.4,1.5,0.4,Iris-setosa -5.4,3.9,1.3,0.4,Iris-setosa -5.1,3.5,1.4,0.3,Iris-setosa -5.7,3.8,1.7,0.3,Iris-setosa -5.1,3.8,1.5,0.3,Iris-setosa -5.4,3.4,1.7,0.2,Iris-setosa -5.1,3.7,1.5,0.4,Iris-setosa -4.6,3.6,1,0.2,Iris-setosa -5.1,3.3,1.7,0.5,Iris-setosa -4.8,3.4,1.9,0.2,Iris-setosa -5,3,1.6,0.2,Iris-setosa -5,3.4,1.6,0.4,Iris-setosa -5.2,3.5,1.5,0.2,Iris-setosa -5.2,3.4,1.4,0.2,Iris-setosa -4.7,3.2,1.6,0.2,Iris-setosa -4.8,3.1,1.6,0.2,Iris-setosa -5.4,3.4,1.5,0.4,Iris-setosa -5.2,4.1,1.5,0.1,Iris-setosa -5.5,4.2,1.4,0.2,Iris-setosa -4.9,3.1,1.5,0.1,Iris-setosa -5,3.2,1.2,0.2,Iris-setosa -5.5,3.5,1.3,0.2,Iris-setosa -4.9,3.1,1.5,0.1,Iris-setosa -4.4,3,1.3,0.2,Iris-setosa -5.1,3.4,1.5,0.2,Iris-setosa -5,3.5,1.3,0.3,Iris-setosa -4.5,2.3,1.3,0.3,Iris-setosa -4.4,3.2,1.3,0.2,Iris-setosa -5,3.5,1.6,0.6,Iris-setosa -5.1,3.8,1.9,0.4,Iris-setosa -4.8,3,1.4,0.3,Iris-setosa -5.1,3.8,1.6,0.2,Iris-setosa -4.6,3.2,1.4,0.2,Iris-setosa -5.3,3.7,1.5,0.2,Iris-setosa -5,3.3,1.4,0.2,Iris-setosa -7,3.2,4.7,1.4,Iris-versicolor -6.4,3.2,4.5,1.5,Iris-versicolor -6.9,3.1,4.9,1.5,Iris-versicolor -5.5,2.3,4,1.3,Iris-versicolor -6.5,2.8,4.6,1.5,Iris-versicolor -5.7,2.8,4.5,1.3,Iris-versicolor -6.3,3.3,4.7,1.6,Iris-versicolor -4.9,2.4,3.3,1,Iris-versicolor -6.6,2.9,4.6,1.3,Iris-versicolor -5.2,2.7,3.9,1.4,Iris-versicolor -5,2,3.5,1,Iris-versicolor -5.9,3,4.2,1.5,Iris-versicolor -6,2.2,4,1,Iris-versicolor -6.1,2.9,4.7,1.4,Iris-versicolor -5.6,2.9,3.6,1.3,Iris-versicolor -6.7,3.1,4.4,1.4,Iris-versicolor -5.6,3,4.5,1.5,Iris-versicolor -5.8,2.7,4.1,1,Iris-versicolor -6.2,2.2,4.5,1.5,Iris-versicolor -5.6,2.5,3.9,1.1,Iris-versicolor -5.9,3.2,4.8,1.8,Iris-versicolor -6.1,2.8,4,1.3,Iris-versicolor -6.3,2.5,4.9,1.5,Iris-versicolor -6.1,2.8,4.7,1.2,Iris-versicolor -6.4,2.9,4.3,1.3,Iris-versicolor -6.6,3,4.4,1.4,Iris-versicolor -6.8,2.8,4.8,1.4,Iris-versicolor -6.7,3,5,1.7,Iris-versicolor -6,2.9,4.5,1.5,Iris-versicolor -5.7,2.6,3.5,1,Iris-versicolor -5.5,2.4,3.8,1.1,Iris-versicolor -5.5,2.4,3.7,1,Iris-versicolor -5.8,2.7,3.9,1.2,Iris-versicolor -6,2.7,5.1,1.6,Iris-versicolor -5.4,3,4.5,1.5,Iris-versicolor -6,3.4,4.5,1.6,Iris-versicolor -6.7,3.1,4.7,1.5,Iris-versicolor -6.3,2.3,4.4,1.3,Iris-versicolor -5.6,3,4.1,1.3,Iris-versicolor -5.5,2.5,4,1.3,Iris-versicolor -5.5,2.6,4.4,1.2,Iris-versicolor -6.1,3,4.6,1.4,Iris-versicolor -5.8,2.6,4,1.2,Iris-versicolor -5,2.3,3.3,1,Iris-versicolor -5.6,2.7,4.2,1.3,Iris-versicolor -5.7,3,4.2,1.2,Iris-versicolor -5.7,2.9,4.2,1.3,Iris-versicolor -6.2,2.9,4.3,1.3,Iris-versicolor -5.1,2.5,3,1.1,Iris-versicolor -5.7,2.8,4.1,1.3,Iris-versicolor -6.3,3.3,6,2.5,Iris-virginica -5.8,2.7,5.1,1.9,Iris-virginica -7.1,3,5.9,2.1,Iris-virginica -6.3,2.9,5.6,1.8,Iris-virginica -6.5,3,5.8,2.2,Iris-virginica -7.6,3,6.6,2.1,Iris-virginica -4.9,2.5,4.5,1.7,Iris-virginica -7.3,2.9,6.3,1.8,Iris-virginica -6.7,2.5,5.8,1.8,Iris-virginica -7.2,3.6,6.1,2.5,Iris-virginica -6.5,3.2,5.1,2,Iris-virginica -6.4,2.7,5.3,1.9,Iris-virginica -6.8,3,5.5,2.1,Iris-virginica -5.7,2.5,5,2,Iris-virginica -5.8,2.8,5.1,2.4,Iris-virginica -6.4,3.2,5.3,2.3,Iris-virginica -6.5,3,5.5,1.8,Iris-virginica -7.7,3.8,6.7,2.2,Iris-virginica -7.7,2.6,6.9,2.3,Iris-virginica -6,2.2,5,1.5,Iris-virginica -6.9,3.2,5.7,2.3,Iris-virginica -5.6,2.8,4.9,2,Iris-virginica -7.7,2.8,6.7,2,Iris-virginica -6.3,2.7,4.9,1.8,Iris-virginica -6.7,3.3,5.7,2.1,Iris-virginica -7.2,3.2,6,1.8,Iris-virginica -6.2,2.8,4.8,1.8,Iris-virginica -6.1,3,4.9,1.8,Iris-virginica -6.4,2.8,5.6,2.1,Iris-virginica -7.2,3,5.8,1.6,Iris-virginica -7.4,2.8,6.1,1.9,Iris-virginica -7.9,3.8,6.4,2,Iris-virginica -6.4,2.8,5.6,2.2,Iris-virginica -6.3,2.8,5.1,1.5,Iris-virginica -6.1,2.6,5.6,1.4,Iris-virginica -7.7,3,6.1,2.3,Iris-virginica -6.3,3.4,5.6,2.4,Iris-virginica -6.4,3.1,5.5,1.8,Iris-virginica -6,3,4.8,1.8,Iris-virginica -6.9,3.1,5.4,2.1,Iris-virginica -6.7,3.1,5.6,2.4,Iris-virginica -6.9,3.1,5.1,2.3,Iris-virginica -5.8,2.7,5.1,1.9,Iris-virginica -6.8,3.2,5.9,2.3,Iris-virginica -6.7,3.3,5.7,2.5,Iris-virginica -6.7,3,5.2,2.3,Iris-virginica -6.3,2.5,5,1.9,Iris-virginica -6.5,3,5.2,2,Iris-virginica -6.2,3.4,5.4,2.3,Iris-virginica -5.9,3,5.1,1.8,Iris-virginica diff --git a/Computational Algorithms/Applications/Ml Algorithms/PCA.ipynb b/Computational Algorithms/Applications/Ml Algorithms/PCA.ipynb deleted file mode 100644 index bac740f..0000000 --- a/Computational Algorithms/Applications/Ml Algorithms/PCA.ipynb +++ /dev/null @@ -1,620 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 123, - "metadata": {}, - "outputs": [], - "source": [ - "# Creating Taining Set\n", - "import numpy as np\n", - "import pandas as pd\n", - "\n", - "df = pd.read_csv('Iris.csv')\n", - "original_data = df.iloc[:,:4]\n" - ] - }, - { - "cell_type": "code", - "execution_count": 124, - "metadata": {}, - "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", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
SepalLengthCmSepalWidthCmPetalLengthCmPetalWidthCmSpecies
05.13.51.40.2Iris-setosa
14.93.01.40.2Iris-setosa
24.73.21.30.2Iris-setosa
34.63.11.50.2Iris-setosa
45.03.61.40.2Iris-setosa
..................
1456.73.05.22.3Iris-virginica
1466.32.55.01.9Iris-virginica
1476.53.05.22.0Iris-virginica
1486.23.45.42.3Iris-virginica
1495.93.05.11.8Iris-virginica
\n", - "

150 rows × 5 columns

\n", - "
" - ], - "text/plain": [ - " SepalLengthCm SepalWidthCm PetalLengthCm PetalWidthCm Species\n", - "0 5.1 3.5 1.4 0.2 Iris-setosa\n", - "1 4.9 3.0 1.4 0.2 Iris-setosa\n", - "2 4.7 3.2 1.3 0.2 Iris-setosa\n", - "3 4.6 3.1 1.5 0.2 Iris-setosa\n", - "4 5.0 3.6 1.4 0.2 Iris-setosa\n", - ".. ... ... ... ... ...\n", - "145 6.7 3.0 5.2 2.3 Iris-virginica\n", - "146 6.3 2.5 5.0 1.9 Iris-virginica\n", - "147 6.5 3.0 5.2 2.0 Iris-virginica\n", - "148 6.2 3.4 5.4 2.3 Iris-virginica\n", - "149 5.9 3.0 5.1 1.8 Iris-virginica\n", - "\n", - "[150 rows x 5 columns]" - ] - }, - "execution_count": 124, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Step-1: Scaling" - ] - }, - { - "cell_type": "code", - "execution_count": 125, - "metadata": {}, - "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", - "
SepalLengthCmSepalWidthCmPetalLengthCmPetalWidthCmSpecies
0-0.9006811.032057-1.341272-1.312977Iris-setosa
1-1.143017-0.124958-1.341272-1.312977Iris-setosa
2-1.3853530.337848-1.398138-1.312977Iris-setosa
3-1.5065210.106445-1.284407-1.312977Iris-setosa
4-1.0218491.263460-1.341272-1.312977Iris-setosa
\n", - "
" - ], - "text/plain": [ - " SepalLengthCm SepalWidthCm PetalLengthCm PetalWidthCm Species\n", - "0 -0.900681 1.032057 -1.341272 -1.312977 Iris-setosa\n", - "1 -1.143017 -0.124958 -1.341272 -1.312977 Iris-setosa\n", - "2 -1.385353 0.337848 -1.398138 -1.312977 Iris-setosa\n", - "3 -1.506521 0.106445 -1.284407 -1.312977 Iris-setosa\n", - "4 -1.021849 1.263460 -1.341272 -1.312977 Iris-setosa" - ] - }, - "execution_count": 125, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "from sklearn.preprocessing import StandardScaler\n", - "scaler = StandardScaler()\n", - "\n", - "df.iloc[:,0:4] = scaler.fit_transform(df.iloc[:,0:4])\n", - "df.head(5)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Step-2: Covariance Matrix" - ] - }, - { - "cell_type": "code", - "execution_count": 126, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[ 1.00671141, -0.11010327, 0.87760486, 0.82344326],\n", - " [-0.11010327, 1.00671141, -0.42333835, -0.358937 ],\n", - " [ 0.87760486, -0.42333835, 1.00671141, 0.96921855],\n", - " [ 0.82344326, -0.358937 , 0.96921855, 1.00671141]])" - ] - }, - "execution_count": 126, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "Cov_mat = np.cov( [ df.iloc[:,0],df.iloc[:,1],df.iloc[:,2],df.iloc[:,3] ] )\n", - "Cov_mat" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Step-3: Eigenval and Eigenvectors" - ] - }, - { - "cell_type": "code", - "execution_count": 127, - "metadata": {}, - "outputs": [], - "source": [ - "eigenval,eigenvec = np.linalg.eig(Cov_mat)" - ] - }, - { - "cell_type": "code", - "execution_count": 128, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([2.93035378, 0.92740362, 0.14834223, 0.02074601])" - ] - }, - "execution_count": 128, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "eigenval" - ] - }, - { - "cell_type": "code", - "execution_count": 129, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[ 0.52237162, -0.37231836, -0.72101681, 0.26199559],\n", - " [-0.26335492, -0.92555649, 0.24203288, -0.12413481],\n", - " [ 0.58125401, -0.02109478, 0.14089226, -0.80115427],\n", - " [ 0.56561105, -0.06541577, 0.6338014 , 0.52354627]])" - ] - }, - "execution_count": 129, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "eigenvec" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## This is the real :: for ith row = ith eigenvalue" - ] - }, - { - "cell_type": "code", - "execution_count": 130, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[ 0.52237162, -0.26335492, 0.58125401, 0.56561105],\n", - " [-0.37231836, -0.92555649, -0.02109478, -0.06541577],\n", - " [-0.72101681, 0.24203288, 0.14089226, 0.6338014 ],\n", - " [ 0.26199559, -0.12413481, -0.80115427, 0.52354627]])" - ] - }, - "execution_count": 130, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "eigenvec.T " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Get Largest Values" - ] - }, - { - "cell_type": "code", - "execution_count": 131, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[ 0.52237162, -0.26335492, 0.58125401, 0.56561105],\n", - " [-0.37231836, -0.92555649, -0.02109478, -0.06541577]])" - ] - }, - "execution_count": 131, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "PC_1_2 = eigenvec.T[:2]\n", - "PC_1_2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Step-4: Transform Data into Reduced Dimension" - ] - }, - { - "cell_type": "code", - "execution_count": 132, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[ 0.52237162, -0.37231836],\n", - " [-0.26335492, -0.92555649],\n", - " [ 0.58125401, -0.02109478],\n", - " [ 0.56561105, -0.06541577]])" - ] - }, - "execution_count": 132, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "transpose_PC = PC_1_2.T\n", - "transpose_PC" - ] - }, - { - "cell_type": "code", - "execution_count": 133, - "metadata": {}, - "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", - "
PC1PC2Species
02.669231-5.180887Iris-setosa
12.696434-4.643645Iris-setosa
22.481163-4.752183Iris-setosa
32.571512-4.626615Iris-setosa
42.590658-5.236211Iris-setosa
............
1457.033251-5.531352Iris-virginica
1466.613485-4.889261Iris-virginica
1476.759094-5.437263Iris-virginica
1486.782974-5.719634Iris-virginica
1496.274423-5.198680Iris-virginica
\n", - "

150 rows × 3 columns

\n", - "
" - ], - "text/plain": [ - " PC1 PC2 Species\n", - "0 2.669231 -5.180887 Iris-setosa\n", - "1 2.696434 -4.643645 Iris-setosa\n", - "2 2.481163 -4.752183 Iris-setosa\n", - "3 2.571512 -4.626615 Iris-setosa\n", - "4 2.590658 -5.236211 Iris-setosa\n", - ".. ... ... ...\n", - "145 7.033251 -5.531352 Iris-virginica\n", - "146 6.613485 -4.889261 Iris-virginica\n", - "147 6.759094 -5.437263 Iris-virginica\n", - "148 6.782974 -5.719634 Iris-virginica\n", - "149 6.274423 -5.198680 Iris-virginica\n", - "\n", - "[150 rows x 3 columns]" - ] - }, - "execution_count": 133, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "Transformed = np.dot(original_data,transpose_PC)\n", - "\n", - "new_df = pd.DataFrame(Transformed,columns=['PC1','PC2'])\n", - "new_df['Species'] = df['Species']\n", - "new_df" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.4" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/Computational Algorithms/Applications/DSA Algorithms/heapify.cpp b/Computational Algorithms/Heaps/heapify.cpp similarity index 100% rename from Computational Algorithms/Applications/DSA Algorithms/heapify.cpp rename to Computational Algorithms/Heaps/heapify.cpp diff --git a/Ml Algorithms/KNN/KNN.ipynb b/Ml Algorithms/KNN/KNN.ipynb new file mode 100644 index 0000000..2388ddb --- /dev/null +++ b/Ml Algorithms/KNN/KNN.ipynb @@ -0,0 +1,354 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# KNN \n", + "### KNN is a lazy runner: as without giving an input algo can't be runned " + ] + }, + { + "cell_type": "code", + "execution_count": 150, + "metadata": {}, + "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", + "
AgeEstimatedSalaryPurchased
019190000
135200000
226430000
327570000
419760000
............
39546410001
39651230001
39750200001
39836330000
39949360001
\n", + "

400 rows × 3 columns

\n", + "
" + ], + "text/plain": [ + " Age EstimatedSalary Purchased\n", + "0 19 19000 0\n", + "1 35 20000 0\n", + "2 26 43000 0\n", + "3 27 57000 0\n", + "4 19 76000 0\n", + ".. ... ... ...\n", + "395 46 41000 1\n", + "396 51 23000 1\n", + "397 50 20000 1\n", + "398 36 33000 0\n", + "399 49 36000 1\n", + "\n", + "[400 rows x 3 columns]" + ] + }, + "execution_count": 150, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import pandas as pd\n", + "import numpy as np\n", + "\n", + "df = pd.read_csv('Social_Network_Ads.csv').iloc[:,2:]\n", + "df" + ] + }, + { + "cell_type": "code", + "execution_count": 151, + "metadata": {}, + "outputs": [], + "source": [ + "from sklearn.preprocessing import StandardScaler\n", + "scale = StandardScaler()\n", + "\n", + "df.iloc[:,:2] = scale.fit_transform(df.iloc[:,:2])" + ] + }, + { + "cell_type": "code", + "execution_count": 152, + "metadata": {}, + "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", + "
AgeEstimatedSalary
180.797057-1.225763
83-0.2535870.536129
2380.7970570.359940
3250.319491-0.286087
103-0.4446142.327385
.........
3161.5611621.005967
3480.1284650.213115
328-0.1580741.417075
149-1.6862840.125021
2421.1791100.536129
\n", + "

280 rows × 2 columns

\n", + "
" + ], + "text/plain": [ + " Age EstimatedSalary\n", + "18 0.797057 -1.225763\n", + "83 -0.253587 0.536129\n", + "238 0.797057 0.359940\n", + "325 0.319491 -0.286087\n", + "103 -0.444614 2.327385\n", + ".. ... ...\n", + "316 1.561162 1.005967\n", + "348 0.128465 0.213115\n", + "328 -0.158074 1.417075\n", + "149 -1.686284 0.125021\n", + "242 1.179110 0.536129\n", + "\n", + "[280 rows x 2 columns]" + ] + }, + "execution_count": 152, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.model_selection import train_test_split\n", + "xtrain,xtest,ytrain,ytest = train_test_split(df.iloc[:,:2],df.iloc[:,-1],test_size=0.3)\n", + "xtrain" + ] + }, + { + "cell_type": "code", + "execution_count": 153, + "metadata": {}, + "outputs": [], + "source": [ + "from sklearn.neighbors import KNeighborsClassifier\n", + "\n", + "knn = KNeighborsClassifier(n_neighbors=1)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 154, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
KNeighborsClassifier(n_neighbors=1)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
" + ], + "text/plain": [ + "KNeighborsClassifier(n_neighbors=1)" + ] + }, + "execution_count": 154, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "knn.fit(xtrain,ytrain)" + ] + }, + { + "cell_type": "code", + "execution_count": 155, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "85.83333333333333" + ] + }, + "execution_count": 155, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.metrics import accuracy_score\n", + "ypred = knn.predict(xtest)\n", + "accuracy_score(ytest,ypred)*100" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.4" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/Ml Algorithms/KNN/Social_Network_Ads.csv b/Ml Algorithms/KNN/Social_Network_Ads.csv new file mode 100644 index 0000000..4a53849 --- /dev/null +++ b/Ml Algorithms/KNN/Social_Network_Ads.csv @@ -0,0 +1,401 @@ +User ID,Gender,Age,EstimatedSalary,Purchased +15624510,Male,19,19000,0 +15810944,Male,35,20000,0 +15668575,Female,26,43000,0 +15603246,Female,27,57000,0 +15804002,Male,19,76000,0 +15728773,Male,27,58000,0 +15598044,Female,27,84000,0 +15694829,Female,32,150000,1 +15600575,Male,25,33000,0 +15727311,Female,35,65000,0 +15570769,Female,26,80000,0 +15606274,Female,26,52000,0 +15746139,Male,20,86000,0 +15704987,Male,32,18000,0 +15628972,Male,18,82000,0 +15697686,Male,29,80000,0 +15733883,Male,47,25000,1 +15617482,Male,45,26000,1 +15704583,Male,46,28000,1 +15621083,Female,48,29000,1 +15649487,Male,45,22000,1 +15736760,Female,47,49000,1 +15714658,Male,48,41000,1 +15599081,Female,45,22000,1 +15705113,Male,46,23000,1 +15631159,Male,47,20000,1 +15792818,Male,49,28000,1 +15633531,Female,47,30000,1 +15744529,Male,29,43000,0 +15669656,Male,31,18000,0 +15581198,Male,31,74000,0 +15729054,Female,27,137000,1 +15573452,Female,21,16000,0 +15776733,Female,28,44000,0 +15724858,Male,27,90000,0 +15713144,Male,35,27000,0 +15690188,Female,33,28000,0 +15689425,Male,30,49000,0 +15671766,Female,26,72000,0 +15782806,Female,27,31000,0 +15764419,Female,27,17000,0 +15591915,Female,33,51000,0 +15772798,Male,35,108000,0 +15792008,Male,30,15000,0 +15715541,Female,28,84000,0 +15639277,Male,23,20000,0 +15798850,Male,25,79000,0 +15776348,Female,27,54000,0 +15727696,Male,30,135000,1 +15793813,Female,31,89000,0 +15694395,Female,24,32000,0 +15764195,Female,18,44000,0 +15744919,Female,29,83000,0 +15671655,Female,35,23000,0 +15654901,Female,27,58000,0 +15649136,Female,24,55000,0 +15775562,Female,23,48000,0 +15807481,Male,28,79000,0 +15642885,Male,22,18000,0 +15789109,Female,32,117000,0 +15814004,Male,27,20000,0 +15673619,Male,25,87000,0 +15595135,Female,23,66000,0 +15583681,Male,32,120000,1 +15605000,Female,59,83000,0 +15718071,Male,24,58000,0 +15679760,Male,24,19000,0 +15654574,Female,23,82000,0 +15577178,Female,22,63000,0 +15595324,Female,31,68000,0 +15756932,Male,25,80000,0 +15726358,Female,24,27000,0 +15595228,Female,20,23000,0 +15782530,Female,33,113000,0 +15592877,Male,32,18000,0 +15651983,Male,34,112000,1 +15746737,Male,18,52000,0 +15774179,Female,22,27000,0 +15667265,Female,28,87000,0 +15655123,Female,26,17000,0 +15595917,Male,30,80000,0 +15668385,Male,39,42000,0 +15709476,Male,20,49000,0 +15711218,Male,35,88000,0 +15798659,Female,30,62000,0 +15663939,Female,31,118000,1 +15694946,Male,24,55000,0 +15631912,Female,28,85000,0 +15768816,Male,26,81000,0 +15682268,Male,35,50000,0 +15684801,Male,22,81000,0 +15636428,Female,30,116000,0 +15809823,Male,26,15000,0 +15699284,Female,29,28000,0 +15786993,Female,29,83000,0 +15709441,Female,35,44000,0 +15710257,Female,35,25000,0 +15582492,Male,28,123000,1 +15575694,Male,35,73000,0 +15756820,Female,28,37000,0 +15766289,Male,27,88000,0 +15593014,Male,28,59000,0 +15584545,Female,32,86000,0 +15675949,Female,33,149000,1 +15672091,Female,19,21000,0 +15801658,Male,21,72000,0 +15706185,Female,26,35000,0 +15789863,Male,27,89000,0 +15720943,Male,26,86000,0 +15697997,Female,38,80000,0 +15665416,Female,39,71000,0 +15660200,Female,37,71000,0 +15619653,Male,38,61000,0 +15773447,Male,37,55000,0 +15739160,Male,42,80000,0 +15689237,Male,40,57000,0 +15679297,Male,35,75000,0 +15591433,Male,36,52000,0 +15642725,Male,40,59000,0 +15701962,Male,41,59000,0 +15811613,Female,36,75000,0 +15741049,Male,37,72000,0 +15724423,Female,40,75000,0 +15574305,Male,35,53000,0 +15678168,Female,41,51000,0 +15697020,Female,39,61000,0 +15610801,Male,42,65000,0 +15745232,Male,26,32000,0 +15722758,Male,30,17000,0 +15792102,Female,26,84000,0 +15675185,Male,31,58000,0 +15801247,Male,33,31000,0 +15725660,Male,30,87000,0 +15638963,Female,21,68000,0 +15800061,Female,28,55000,0 +15578006,Male,23,63000,0 +15668504,Female,20,82000,0 +15687491,Male,30,107000,1 +15610403,Female,28,59000,0 +15741094,Male,19,25000,0 +15807909,Male,19,85000,0 +15666141,Female,18,68000,0 +15617134,Male,35,59000,0 +15783029,Male,30,89000,0 +15622833,Female,34,25000,0 +15746422,Female,24,89000,0 +15750839,Female,27,96000,1 +15749130,Female,41,30000,0 +15779862,Male,29,61000,0 +15767871,Male,20,74000,0 +15679651,Female,26,15000,0 +15576219,Male,41,45000,0 +15699247,Male,31,76000,0 +15619087,Female,36,50000,0 +15605327,Male,40,47000,0 +15610140,Female,31,15000,0 +15791174,Male,46,59000,0 +15602373,Male,29,75000,0 +15762605,Male,26,30000,0 +15598840,Female,32,135000,1 +15744279,Male,32,100000,1 +15670619,Male,25,90000,0 +15599533,Female,37,33000,0 +15757837,Male,35,38000,0 +15697574,Female,33,69000,0 +15578738,Female,18,86000,0 +15762228,Female,22,55000,0 +15614827,Female,35,71000,0 +15789815,Male,29,148000,1 +15579781,Female,29,47000,0 +15587013,Male,21,88000,0 +15570932,Male,34,115000,0 +15794661,Female,26,118000,0 +15581654,Female,34,43000,0 +15644296,Female,34,72000,0 +15614420,Female,23,28000,0 +15609653,Female,35,47000,0 +15594577,Male,25,22000,0 +15584114,Male,24,23000,0 +15673367,Female,31,34000,0 +15685576,Male,26,16000,0 +15774727,Female,31,71000,0 +15694288,Female,32,117000,1 +15603319,Male,33,43000,0 +15759066,Female,33,60000,0 +15814816,Male,31,66000,0 +15724402,Female,20,82000,0 +15571059,Female,33,41000,0 +15674206,Male,35,72000,0 +15715160,Male,28,32000,0 +15730448,Male,24,84000,0 +15662067,Female,19,26000,0 +15779581,Male,29,43000,0 +15662901,Male,19,70000,0 +15689751,Male,28,89000,0 +15667742,Male,34,43000,0 +15738448,Female,30,79000,0 +15680243,Female,20,36000,0 +15745083,Male,26,80000,0 +15708228,Male,35,22000,0 +15628523,Male,35,39000,0 +15708196,Male,49,74000,0 +15735549,Female,39,134000,1 +15809347,Female,41,71000,0 +15660866,Female,58,101000,1 +15766609,Female,47,47000,0 +15654230,Female,55,130000,1 +15794566,Female,52,114000,0 +15800890,Female,40,142000,1 +15697424,Female,46,22000,0 +15724536,Female,48,96000,1 +15735878,Male,52,150000,1 +15707596,Female,59,42000,0 +15657163,Male,35,58000,0 +15622478,Male,47,43000,0 +15779529,Female,60,108000,1 +15636023,Male,49,65000,0 +15582066,Male,40,78000,0 +15666675,Female,46,96000,0 +15732987,Male,59,143000,1 +15789432,Female,41,80000,0 +15663161,Male,35,91000,1 +15694879,Male,37,144000,1 +15593715,Male,60,102000,1 +15575002,Female,35,60000,0 +15622171,Male,37,53000,0 +15795224,Female,36,126000,1 +15685346,Male,56,133000,1 +15691808,Female,40,72000,0 +15721007,Female,42,80000,1 +15794253,Female,35,147000,1 +15694453,Male,39,42000,0 +15813113,Male,40,107000,1 +15614187,Male,49,86000,1 +15619407,Female,38,112000,0 +15646227,Male,46,79000,1 +15660541,Male,40,57000,0 +15753874,Female,37,80000,0 +15617877,Female,46,82000,0 +15772073,Female,53,143000,1 +15701537,Male,42,149000,1 +15736228,Male,38,59000,0 +15780572,Female,50,88000,1 +15769596,Female,56,104000,1 +15586996,Female,41,72000,0 +15722061,Female,51,146000,1 +15638003,Female,35,50000,0 +15775590,Female,57,122000,1 +15730688,Male,41,52000,0 +15753102,Female,35,97000,1 +15810075,Female,44,39000,0 +15723373,Male,37,52000,0 +15795298,Female,48,134000,1 +15584320,Female,37,146000,1 +15724161,Female,50,44000,0 +15750056,Female,52,90000,1 +15609637,Female,41,72000,0 +15794493,Male,40,57000,0 +15569641,Female,58,95000,1 +15815236,Female,45,131000,1 +15811177,Female,35,77000,0 +15680587,Male,36,144000,1 +15672821,Female,55,125000,1 +15767681,Female,35,72000,0 +15600379,Male,48,90000,1 +15801336,Female,42,108000,1 +15721592,Male,40,75000,0 +15581282,Male,37,74000,0 +15746203,Female,47,144000,1 +15583137,Male,40,61000,0 +15680752,Female,43,133000,0 +15688172,Female,59,76000,1 +15791373,Male,60,42000,1 +15589449,Male,39,106000,1 +15692819,Female,57,26000,1 +15727467,Male,57,74000,1 +15734312,Male,38,71000,0 +15764604,Male,49,88000,1 +15613014,Female,52,38000,1 +15759684,Female,50,36000,1 +15609669,Female,59,88000,1 +15685536,Male,35,61000,0 +15750447,Male,37,70000,1 +15663249,Female,52,21000,1 +15638646,Male,48,141000,0 +15734161,Female,37,93000,1 +15631070,Female,37,62000,0 +15761950,Female,48,138000,1 +15649668,Male,41,79000,0 +15713912,Female,37,78000,1 +15586757,Male,39,134000,1 +15596522,Male,49,89000,1 +15625395,Male,55,39000,1 +15760570,Male,37,77000,0 +15566689,Female,35,57000,0 +15725794,Female,36,63000,0 +15673539,Male,42,73000,1 +15705298,Female,43,112000,1 +15675791,Male,45,79000,0 +15747043,Male,46,117000,1 +15736397,Female,58,38000,1 +15678201,Male,48,74000,1 +15720745,Female,37,137000,1 +15637593,Male,37,79000,1 +15598070,Female,40,60000,0 +15787550,Male,42,54000,0 +15603942,Female,51,134000,0 +15733973,Female,47,113000,1 +15596761,Male,36,125000,1 +15652400,Female,38,50000,0 +15717893,Female,42,70000,0 +15622585,Male,39,96000,1 +15733964,Female,38,50000,0 +15753861,Female,49,141000,1 +15747097,Female,39,79000,0 +15594762,Female,39,75000,1 +15667417,Female,54,104000,1 +15684861,Male,35,55000,0 +15742204,Male,45,32000,1 +15623502,Male,36,60000,0 +15774872,Female,52,138000,1 +15611191,Female,53,82000,1 +15674331,Male,41,52000,0 +15619465,Female,48,30000,1 +15575247,Female,48,131000,1 +15695679,Female,41,60000,0 +15713463,Male,41,72000,0 +15785170,Female,42,75000,0 +15796351,Male,36,118000,1 +15639576,Female,47,107000,1 +15693264,Male,38,51000,0 +15589715,Female,48,119000,1 +15769902,Male,42,65000,0 +15587177,Male,40,65000,0 +15814553,Male,57,60000,1 +15601550,Female,36,54000,0 +15664907,Male,58,144000,1 +15612465,Male,35,79000,0 +15810800,Female,38,55000,0 +15665760,Male,39,122000,1 +15588080,Female,53,104000,1 +15776844,Male,35,75000,0 +15717560,Female,38,65000,0 +15629739,Female,47,51000,1 +15729908,Male,47,105000,1 +15716781,Female,41,63000,0 +15646936,Male,53,72000,1 +15768151,Female,54,108000,1 +15579212,Male,39,77000,0 +15721835,Male,38,61000,0 +15800515,Female,38,113000,1 +15591279,Male,37,75000,0 +15587419,Female,42,90000,1 +15750335,Female,37,57000,0 +15699619,Male,36,99000,1 +15606472,Male,60,34000,1 +15778368,Male,54,70000,1 +15671387,Female,41,72000,0 +15573926,Male,40,71000,1 +15709183,Male,42,54000,0 +15577514,Male,43,129000,1 +15778830,Female,53,34000,1 +15768072,Female,47,50000,1 +15768293,Female,42,79000,0 +15654456,Male,42,104000,1 +15807525,Female,59,29000,1 +15574372,Female,58,47000,1 +15671249,Male,46,88000,1 +15779744,Male,38,71000,0 +15624755,Female,54,26000,1 +15611430,Female,60,46000,1 +15774744,Male,60,83000,1 +15629885,Female,39,73000,0 +15708791,Male,59,130000,1 +15793890,Female,37,80000,0 +15646091,Female,46,32000,1 +15596984,Female,46,74000,0 +15800215,Female,42,53000,0 +15577806,Male,41,87000,1 +15749381,Female,58,23000,1 +15683758,Male,42,64000,0 +15670615,Male,48,33000,1 +15715622,Female,44,139000,1 +15707634,Male,49,28000,1 +15806901,Female,57,33000,1 +15775335,Male,56,60000,1 +15724150,Female,49,39000,1 +15627220,Male,39,71000,0 +15672330,Male,47,34000,1 +15668521,Female,48,35000,1 +15807837,Male,48,33000,1 +15592570,Male,47,23000,1 +15748589,Female,45,45000,1 +15635893,Male,60,42000,1 +15757632,Female,39,59000,0 +15691863,Female,46,41000,1 +15706071,Male,51,23000,1 +15654296,Female,50,20000,1 +15755018,Male,36,33000,0 +15594041,Female,49,36000,1 \ No newline at end of file