Dataset Viewer (First 5GB)
Auto-converted to Parquet
Search is not available for this dataset
text
stringlengths
1.62k
105M
id
stringlengths
21
24
file_path
stringclasses
45 values
{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.7.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"<div style=\"color:white;\n display:fill;\n border-radius:20px;\n background-color:#F5DEB3;\n font-size:170%;\n font-family:Helvetica, Sans-Serif;\n letter-spacing:0.5px\">\n<p style=\"padding: 10px;\n text-align: center;\n font-size:150%;\n color:blue;\">\n 馃捁馃馃捁SVM on Loan Data馃捁馃馃捁\n \n</p>\n<style>\n h1{text-align: center;}\n</style> \n \n</div>","metadata":{}},{"cell_type":"markdown","source":"<p style=\"font-family:cursive; font-size:18px; color:'darkcyan';\">I brewed this notebook from scratch, If this notebook helped, please consider upvoting and cite me if sharing ,Thank you!</p>\n鈥媆n<p style=\"width: 700px;padding: 20px;background: papayawhip;border-radius:10px;font-size:18px;border-radius:20px\">\n <a href=\"https://www.linkedin.com/in/tusharaggarwalinseec/\" target=\"_blank\">Lets connect on LinkedIn!</a>\n \n </p>\n<p style=\"width: 700px;padding: 20px;background: papayawhip;border-radius:10px;font-size:18px;border-radius:20px\">\n<a href=\"https://github.com/tushar2704\" target=\"_blank\">Follow me on Github too!</a> </p>\n<p style=\"width: 700px;padding: 20px;background: papayawhip;border-radius:10px;font-size:18px;border-radius:20px\">\n <a href=\"https://medium.com/@tushar_aggarwal\" target=\"_blank\">Also checkout my Medium posts!</a>\n \n </p>","metadata":{}},{"cell_type":"markdown","source":"<div class=\"alert alert-info\" role=\"alert\" style=\"font-size:17px;border-radius:20px\">\n <b>In this project, I am using SVM algorithm on Loan Approval data to uncover based on given features whether the loan will get approved or not,</b>\n \n</div>\n<div class=\"alert alert-info\" role=\"alert\" style=\"font-size:15px;border-radius:20px\">\n <b>Some things to note:</b>\n <br><br>SVM is the Supervised Machine Learning algorithm used for both classification, regression. But mostly preferred for classification, hence in this notebook also i am using for classification,\n <br><br>\n Given a dataset, the algorithm tries to divide the data using hyperplanes and then makes the predictions. SVM is a non-probabilistic linear classifier. While other classifiers, when classifying, predict the probability of a data point to belong to one group or the another, SVM directly says to which group the datapoint belongs to without using any probability calculation.\n <br><br>\n <a href=\"https://scikit-learn.org/stable/modules/svm.html\" target=\"_blank\">For more on SVM click here!</a>\n</div>","metadata":{}},{"cell_type":"markdown","source":"<p style=\"width: 700px;padding: 20px;background: papayawhip;border-radius:10px;font-size:17px;border-radius:20px\">Importing the required Libraries\n \n </p>","metadata":{}},{"cell_type":"code","source":"#Basic liabraries\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\n%matplotlib inline\nimport seaborn as sns\n\n","metadata":{"execution":{"iopub.status.busy":"2023-01-11T12:04:01.133842Z","iopub.execute_input":"2023-01-11T12:04:01.134300Z","iopub.status.idle":"2023-01-11T12:04:01.766076Z","shell.execute_reply.started":"2023-01-11T12:04:01.134273Z","shell.execute_reply":"2023-01-11T12:04:01.764144Z"},"trusted":true},"execution_count":2,"outputs":[]},{"cell_type":"markdown","source":"<p style=\"width: 700px;padding: 20px;background: papayawhip;border-radius:10px;font-size:17px;border-radius:20px\">Loading the Loan data\n <br><a href=\"https://www.kaggle.com/datasets/tusharaggarwal27/loan-dataset\" target=\"_blank\">Get yours here!</a>\n </p>","metadata":{}},{"cell_type":"code","source":"#Loading into the dataframe named 'loan_data'\nloan_data=pd.read_csv(\"/kaggle/input/loan-dataset/loan_approved.csv\")\n\n#Reviewing some top rows to check\nprint(loan_data.head())","metadata":{"execution":{"iopub.status.busy":"2023-01-11T12:08:45.664064Z","iopub.execute_input":"2023-01-11T12:08:45.664490Z","iopub.status.idle":"2023-01-11T12:08:45.693398Z","shell.execute_reply.started":"2023-01-11T12:08:45.664463Z","shell.execute_reply":"2023-01-11T12:08:45.692580Z"},"trusted":true},"execution_count":7,"outputs":[{"name":"stdout","text":" Loan_ID Gender Married Dependents Education Self_Employed \\\n0 LP001002 Male No 0 Graduate No \n1 LP001003 Male Yes 1 Graduate No \n2 LP001005 Male Yes 0 Graduate Yes \n3 LP001006 Male Yes 0 Not Graduate No \n4 LP001008 Male No 0 Graduate No \n\n ApplicantIncome CoapplicantIncome LoanAmount Loan_Amount_Term \\\n0 5849 0.0 NaN 360.0 \n1 4583 1508.0 128.0 360.0 \n2 3000 0.0 66.0 360.0 \n3 2583 2358.0 120.0 360.0 \n4 6000 0.0 141.0 360.0 \n\n Credit_History Property_Area Loan_Status (Approved) \n0 1.0 Urban Y \n1 1.0 Rural N \n2 1.0 Urban Y \n3 1.0 Urban Y \n4 1.0 Urban Y \n","output_type":"stream"}]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}
0116/083/116083402.ipynb
s3://data-agents/kaggle-outputs/sharded/002_00116.jsonl.gz
{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "274dd027", "metadata": { "execution": { "iopub.execute_input": "2023-01-11T12:11:19.961334Z", "iopub.status.busy": "2023-01-11T12:11:19.960866Z", "iopub.status.idle": "2023-01-11T12:11:21.352898Z", "shell.execute_reply": "2023-01-11T12:11:21.351871Z" }, "papermill": { "duration": 1.400811, "end_time": "2023-01-11T12:11:21.355967", "exception": false, "start_time": "2023-01-11T12:11:19.955156", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "#Firstly importing libraries. I like to import all of the one's I used in analysis so if I need to come back to them \n", "#i won't get unnecessary errors\n", "import numpy as np\n", "import pandas as pd\n", "import scipy\n", "import matplotlib.pyplot as plt\n", "from pylab import rcParams\n", "import urllib\n", "import sklearn\n", "from sklearn.preprocessing import OneHotEncoder\n", "from sklearn.neighbors import KNeighborsClassifier\n", "from sklearn import neighbors\n", "from sklearn import tree, model_selection\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.model_selection import cross_val_score, KFold\n", "from sklearn import metrics\n", "from sklearn.metrics import classification_report, confusion_matrix\n", "from sklearn.preprocessing import StandardScaler,MinMaxScaler,RobustScaler,MaxAbsScaler\n", "from sklearn import utils\n", "from sklearn.model_selection import cross_val_score\n", "from sklearn.linear_model import LogisticRegression, LinearRegression\n", "from sklearn.model_selection import GridSearchCV\n", "import scipy.stats as st" ] }, { "cell_type": "code", "execution_count": 2, "id": "e6873ea6", "metadata": { "execution": { "iopub.execute_input": "2023-01-11T12:11:21.363798Z", "iopub.status.busy": "2023-01-11T12:11:21.363402Z", "iopub.status.idle": "2023-01-11T12:11:21.421574Z", "shell.execute_reply": "2023-01-11T12:11:21.420572Z" }, "papermill": { "duration": 0.065058, "end_time": "2023-01-11T12:11:21.424312", "exception": false, "start_time": "2023-01-11T12:11:21.359254", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "#Next I load the dataset from https://www.kaggle.com/thedevastator on predicting student dropout rate\n", "\n", "students = pd.read_csv('/kaggle/input/higher-education-predictors-of-student-retention/dataset.csv')\n", "\n", "#In case I need to drop some columns that are skewing the results I create another df\n", "students_reduced = students#.drop(columns = \"Marital status\")\n", "#col is the number of columns in active df\n", "col = 34" ] }, { "cell_type": "code", "execution_count": 3, "id": "0aa451f5", "metadata": { "execution": { "iopub.execute_input": "2023-01-11T12:11:21.431647Z", "iopub.status.busy": "2023-01-11T12:11:21.431265Z", "iopub.status.idle": "2023-01-11T12:11:21.444399Z", "shell.execute_reply": "2023-01-11T12:11:21.443488Z" }, "papermill": { "duration": 0.019291, "end_time": "2023-01-11T12:11:21.446588", "exception": false, "start_time": "2023-01-11T12:11:21.427297", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "#We need 1 or 0 in the target column so I create an array and change dropout to 1 and graduate to 0 and replace it.\n", "target=students_reduced.iloc[:,col]\n", "target=np.array(target) \n", "for i in range(len(target)):\n", " if target[i] == \"Dropout\": target[i] = '1'\n", " if target[i] == \"Graduate\": target[i] = '0' \n", "students_reduced[\"Target\"] = target" ] }, { "cell_type": "code", "execution_count": 4, "id": "4a8120be", "metadata": { "execution": { "iopub.execute_input": "2023-01-11T12:11:21.454727Z", "iopub.status.busy": "2023-01-11T12:11:21.454157Z", "iopub.status.idle": "2023-01-11T12:11:21.466690Z", "shell.execute_reply": "2023-01-11T12:11:21.465571Z" }, "papermill": { "duration": 0.019566, "end_time": "2023-01-11T12:11:21.469307", "exception": false, "start_time": "2023-01-11T12:11:21.449741", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "#In the target column there are also students that are enrolled and we dont need those in analysis so we drop them, as well\n", "#as random numbers that got created along the way\n", "students_reduced = students_reduced[students_reduced.Target != 'Enrolled'] \n", "students_reduced = students_reduced[(students_reduced.Target != '1') | (students_reduced.Target != '0')]" ] }, { "cell_type": "code", "execution_count": 5, "id": "5f11a08c", "metadata": { "execution": { "iopub.execute_input": "2023-01-11T12:11:21.477304Z", "iopub.status.busy": "2023-01-11T12:11:21.476555Z", "iopub.status.idle": "2023-01-11T12:11:21.484235Z", "shell.execute_reply": "2023-01-11T12:11:21.482826Z" }, "papermill": { "duration": 0.014723, "end_time": "2023-01-11T12:11:21.487154", "exception": false, "start_time": "2023-01-11T12:11:21.472431", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "#Next we set X as all the columns beside the target and y as the target\n", "X = students_reduced.iloc[:, :-1].values\n", "y = students_reduced.iloc[:, col].values" ] }, { "cell_type": "code", "execution_count": 6, "id": "0e69247a", "metadata": { "execution": { "iopub.execute_input": "2023-01-11T12:11:21.495412Z", "iopub.status.busy": "2023-01-11T12:11:21.494949Z", "iopub.status.idle": "2023-01-11T12:11:21.502438Z", "shell.execute_reply": "2023-01-11T12:11:21.501545Z" }, "papermill": { "duration": 0.014287, "end_time": "2023-01-11T12:11:21.504768", "exception": false, "start_time": "2023-01-11T12:11:21.490481", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "#We use the StandardScaler on the X data\n", "scaler = StandardScaler()\n", "scaler.fit(X)\n", "X = scaler.transform(X)\n" ] }, { "cell_type": "code", "execution_count": 7, "id": "bb884bff", "metadata": { "execution": { "iopub.execute_input": "2023-01-11T12:11:21.513339Z", "iopub.status.busy": "2023-01-11T12:11:21.512481Z", "iopub.status.idle": "2023-01-11T12:11:21.528616Z", "shell.execute_reply": "2023-01-11T12:11:21.527387Z" }, "papermill": { "duration": 0.023375, "end_time": "2023-01-11T12:11:21.531558", "exception": false, "start_time": "2023-01-11T12:11:21.508183", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "KNeighborsClassifier(n_neighbors=8, weights='distance')" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#We use the train_test_split function\n", "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)\n", "#We use KNN function as the classifier\n", "classifier = KNeighborsClassifier(n_neighbors=8, weights='distance')\n", "#Then we fit X_train and y_train\n", "classifier.fit(X_train, y_train)" ] }, { "cell_type": "code", "execution_count": 8, "id": "689e0c11", "metadata": { "execution": { "iopub.execute_input": "2023-01-11T12:11:21.540291Z", "iopub.status.busy": "2023-01-11T12:11:21.539637Z", "iopub.status.idle": "2023-01-11T12:12:18.372047Z", "shell.execute_reply": "2023-01-11T12:12:18.370401Z" }, "papermill": { "duration": 56.848879, "end_time": "2023-01-11T12:12:18.383789", "exception": false, "start_time": "2023-01-11T12:11:21.534910", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "GridSearchCV(cv=10,\n", " estimator=KNeighborsClassifier(n_neighbors=8, weights='distance'),\n", " param_grid={'algorithm': ['auto', 'ball_tree', 'kd_tree', 'brute'],\n", " 'n_neighbors': [1, 2, 3, 4, 8, 9, 14, 19, 20, 25],\n", " 'weights': ['uniform', 'distance']},\n", " scoring='accuracy')" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#To find the most effective parameter combination of KNeighborsClassifier we use grid_search where we set the Map first and \n", "#then we fit it on X and y axes\n", "grid_search_params = {\n", " 'n_neighbors' : [1,2,3,4,8,9,14,19,20,25],\n", " 'weights' : ['uniform','distance'],\n", " 'algorithm' : ['auto','ball_tree','kd_tree','brute']\n", " }\n", "gs = GridSearchCV(classifier, grid_search_params, cv = 10, scoring=\"accuracy\")\n", "gs.fit(X,y)" ] }, { "cell_type": "code", "execution_count": 9, "id": "25f41012", "metadata": { "execution": { "iopub.execute_input": "2023-01-11T12:12:18.402850Z", "iopub.status.busy": "2023-01-11T12:12:18.402071Z", "iopub.status.idle": "2023-01-11T12:12:18.420545Z", "shell.execute_reply": "2023-01-11T12:12:18.418812Z" }, "papermill": { "duration": 0.031957, "end_time": "2023-01-11T12:12:18.423892", "exception": false, "start_time": "2023-01-11T12:12:18.391935", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Best parameters: KNeighborsClassifier(n_neighbors=8, weights='distance')\n", "Best score : 0.8608815426997245\n" ] } ], "source": [ "#Last but not least we print out the best parameters and the best score which in this case is :\n", "#Best parameters: KNeighborsClassifier(n_neighbors=8, weights='distance')\n", "#Score : 0.8608815426997245\n", "print(\"Best parameters:\",gs.best_estimator_)\n", "print(\"Best score :\",gs.best_score_)" ] }, { "cell_type": "markdown", "id": "6dd71d6b", "metadata": { "papermill": { "duration": 0.003218, "end_time": "2023-01-11T12:12:18.430947", "exception": false, "start_time": "2023-01-11T12:12:18.427729", "status": "completed" }, "tags": [] }, "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.7.12" }, "papermill": { "default_parameters": {}, "duration": 67.796899, "end_time": "2023-01-11T12:12:19.156586", "environment_variables": {}, "exception": null, "input_path": "__notebook__.ipynb", "output_path": "__notebook__.ipynb", "parameters": {}, "start_time": "2023-01-11T12:11:11.359687", "version": "2.3.4" } }, "nbformat": 4, "nbformat_minor": 5 }
0116/083/116083576.ipynb
s3://data-agents/kaggle-outputs/sharded/002_00116.jsonl.gz
"{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"id\": \"623726(...TRUNCATED)
0116/083/116083878.ipynb
s3://data-agents/kaggle-outputs/sharded/002_00116.jsonl.gz
"{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"id\": \"603a3d(...TRUNCATED)
0116/084/116084048.ipynb
s3://data-agents/kaggle-outputs/sharded/002_00116.jsonl.gz
"{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"id\": \"decfc8(...TRUNCATED)
0116/084/116084163.ipynb
s3://data-agents/kaggle-outputs/sharded/002_00116.jsonl.gz
"{\"metadata\":{\"kernelspec\":{\"language\":\"python\",\"display_name\":\"Python 3\",\"name\":\"pyt(...TRUNCATED)
0116/084/116084883.ipynb
s3://data-agents/kaggle-outputs/sharded/002_00116.jsonl.gz
"{\"metadata\":{\"colab\":{\"provenance\":[],\"machine_shape\":\"hm\"},\"kernelspec\":{\"display_nam(...TRUNCATED)
0116/084/116084930.ipynb
s3://data-agents/kaggle-outputs/sharded/002_00116.jsonl.gz
"{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"id\": \"87a606f7\",\n \"metadata\": (...TRUNCATED)
0116/084/116084958.ipynb
s3://data-agents/kaggle-outputs/sharded/002_00116.jsonl.gz
"{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"id\": \"a7e20713\",\n \"metadata\": (...TRUNCATED)
0116/085/116085014.ipynb
s3://data-agents/kaggle-outputs/sharded/002_00116.jsonl.gz
"{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"id\": \"e5748b(...TRUNCATED)
0116/085/116085099.ipynb
s3://data-agents/kaggle-outputs/sharded/002_00116.jsonl.gz
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
25