{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-02-09T14:20:12.348775Z","iopub.execute_input":"2023-02-09T14:20:12.350356Z","iopub.status.idle":"2023-02-09T14:20:12.390171Z","shell.execute_reply.started":"2023-02-09T14:20:12.350207Z","shell.execute_reply":"2023-02-09T14:20:12.388977Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\ndataset=pd.read_csv(\"/kaggle/input/employee-future-prediction/Employee.csv\")\ndataset","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:12.392069Z","iopub.execute_input":"2023-02-09T14:20:12.392396Z","iopub.status.idle":"2023-02-09T14:20:12.444132Z","shell.execute_reply.started":"2023-02-09T14:20:12.392366Z","shell.execute_reply":"2023-02-09T14:20:12.442603Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataset.isnull()","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:12.445776Z","iopub.execute_input":"2023-02-09T14:20:12.446148Z","iopub.status.idle":"2023-02-09T14:20:12.472514Z","shell.execute_reply.started":"2023-02-09T14:20:12.446114Z","shell.execute_reply":"2023-02-09T14:20:12.471016Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataset.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:12.474036Z","iopub.execute_input":"2023-02-09T14:20:12.474496Z","iopub.status.idle":"2023-02-09T14:20:12.491675Z","shell.execute_reply.started":"2023-02-09T14:20:12.474461Z","shell.execute_reply":"2023-02-09T14:20:12.490356Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataset.info()","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:12.495551Z","iopub.execute_input":"2023-02-09T14:20:12.495964Z","iopub.status.idle":"2023-02-09T14:20:12.524154Z","shell.execute_reply.started":"2023-02-09T14:20:12.495927Z","shell.execute_reply":"2023-02-09T14:20:12.522837Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataset","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:12.525888Z","iopub.execute_input":"2023-02-09T14:20:12.526364Z","iopub.status.idle":"2023-02-09T14:20:12.549812Z","shell.execute_reply.started":"2023-02-09T14:20:12.526317Z","shell.execute_reply":"2023-02-09T14:20:12.54835Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\nl=LabelEncoder()\ndataset[\"Education\"]=l.fit_transform(dataset[\"Education\"])\ndataset[\"City\"]=l.fit_transform(dataset[\"City\"])\ndataset[\"Gender\"]=l.fit_transform(dataset[\"Gender\"])\ndataset[\"EverBenched\"]=l.fit_transform(dataset[\"EverBenched\"])","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:12.551322Z","iopub.execute_input":"2023-02-09T14:20:12.551728Z","iopub.status.idle":"2023-02-09T14:20:13.107545Z","shell.execute_reply.started":"2023-02-09T14:20:12.551693Z","shell.execute_reply":"2023-02-09T14:20:13.106235Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataset","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:13.110861Z","iopub.execute_input":"2023-02-09T14:20:13.111594Z","iopub.status.idle":"2023-02-09T14:20:13.131483Z","shell.execute_reply.started":"2023-02-09T14:20:13.11155Z","shell.execute_reply":"2023-02-09T14:20:13.130336Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x=dataset.iloc[:,:-1]\ny=dataset.iloc[:,-1]","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:13.133257Z","iopub.execute_input":"2023-02-09T14:20:13.133989Z","iopub.status.idle":"2023-02-09T14:20:13.144531Z","shell.execute_reply.started":"2023-02-09T14:20:13.133928Z","shell.execute_reply":"2023-02-09T14:20:13.142706Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:13.146877Z","iopub.execute_input":"2023-02-09T14:20:13.147341Z","iopub.status.idle":"2023-02-09T14:20:13.171716Z","shell.execute_reply.started":"2023-02-09T14:20:13.147304Z","shell.execute_reply":"2023-02-09T14:20:13.17063Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y.value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:13.175517Z","iopub.execute_input":"2023-02-09T14:20:13.175937Z","iopub.status.idle":"2023-02-09T14:20:13.18526Z","shell.execute_reply.started":"2023-02-09T14:20:13.175902Z","shell.execute_reply":"2023-02-09T14:20:13.184086Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from imblearn.over_sampling import RandomOverSampler\nsm=RandomOverSampler()\nx_data,y_data=sm.fit_resample(x,y)","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:13.186714Z","iopub.execute_input":"2023-02-09T14:20:13.187163Z","iopub.status.idle":"2023-02-09T14:20:13.639889Z","shell.execute_reply.started":"2023-02-09T14:20:13.187096Z","shell.execute_reply":"2023-02-09T14:20:13.638558Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from collections import Counter\nprint(Counter(y))","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:13.641169Z","iopub.execute_input":"2023-02-09T14:20:13.641518Z","iopub.status.idle":"2023-02-09T14:20:13.649641Z","shell.execute_reply.started":"2023-02-09T14:20:13.641485Z","shell.execute_reply":"2023-02-09T14:20:13.648156Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import StandardScaler\nsc=StandardScaler()\nscaler=sc.fit_transform(x_data)","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:13.651797Z","iopub.execute_input":"2023-02-09T14:20:13.652198Z","iopub.status.idle":"2023-02-09T14:20:13.667507Z","shell.execute_reply.started":"2023-02-09T14:20:13.652164Z","shell.execute_reply":"2023-02-09T14:20:13.665937Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"scaler","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:13.669131Z","iopub.execute_input":"2023-02-09T14:20:13.669503Z","iopub.status.idle":"2023-02-09T14:20:13.679837Z","shell.execute_reply.started":"2023-02-09T14:20:13.669471Z","shell.execute_reply":"2023-02-09T14:20:13.678256Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\nx_train,x_test,y_train,y_test=train_test_split(scaler,y_data,random_state=13,test_size=0.1)","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:13.681948Z","iopub.execute_input":"2023-02-09T14:20:13.682353Z","iopub.status.idle":"2023-02-09T14:20:13.692861Z","shell.execute_reply.started":"2023-02-09T14:20:13.682298Z","shell.execute_reply":"2023-02-09T14:20:13.691414Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.tree import DecisionTreeClassifier\ndt=DecisionTreeClassifier()\ndt.fit(x_train,y_train)","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:13.694545Z","iopub.execute_input":"2023-02-09T14:20:13.695147Z","iopub.status.idle":"2023-02-09T14:20:13.71758Z","shell.execute_reply.started":"2023-02-09T14:20:13.695106Z","shell.execute_reply":"2023-02-09T14:20:13.716206Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.neighbors import KNeighborsClassifier\nknn=KNeighborsClassifier(n_neighbors=5,metric=\"minkowski\",p=2)\nknn.fit(x_train,y_train)","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:13.719413Z","iopub.execute_input":"2023-02-09T14:20:13.71995Z","iopub.status.idle":"2023-02-09T14:20:13.738175Z","shell.execute_reply.started":"2023-02-09T14:20:13.719903Z","shell.execute_reply":"2023-02-09T14:20:13.736506Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.svm import SVC\nsvm=SVC(kernel=\"linear\")\nsvm.fit(x_train,y_train)","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:13.739367Z","iopub.execute_input":"2023-02-09T14:20:13.740862Z","iopub.status.idle":"2023-02-09T14:20:15.548348Z","shell.execute_reply.started":"2023-02-09T14:20:13.740796Z","shell.execute_reply":"2023-02-09T14:20:15.546672Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.ensemble import VotingClassifier\nvc=VotingClassifier(estimators=[(\"dt\",dt),(\"knn\",knn),(\"svm\",svm)])\nvc.fit(x_train,y_train)","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:15.552012Z","iopub.execute_input":"2023-02-09T14:20:15.552399Z","iopub.status.idle":"2023-02-09T14:20:17.296719Z","shell.execute_reply.started":"2023-02-09T14:20:15.552367Z","shell.execute_reply":"2023-02-09T14:20:17.295563Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import StratifiedKFold\nfrom sklearn.model_selection import cross_val_score\nfrom sklearn.model_selection import cross_val_predict","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:17.298385Z","iopub.execute_input":"2023-02-09T14:20:17.298802Z","iopub.status.idle":"2023-02-09T14:20:17.303558Z","shell.execute_reply.started":"2023-02-09T14:20:17.298739Z","shell.execute_reply":"2023-02-09T14:20:17.302384Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"skf=StratifiedKFold(shuffle=True,n_splits=5)\nskf.get_n_splits(x_train,y_train)","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:17.305076Z","iopub.execute_input":"2023-02-09T14:20:17.305442Z","iopub.status.idle":"2023-02-09T14:20:17.319692Z","shell.execute_reply.started":"2023-02-09T14:20:17.305409Z","shell.execute_reply":"2023-02-09T14:20:17.318382Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"score=cross_val_score(vc,x_train,y_train,cv=skf)\n\npred=cross_val_predict(vc,x_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:17.321663Z","iopub.execute_input":"2023-02-09T14:20:17.322562Z","iopub.status.idle":"2023-02-09T14:20:23.34677Z","shell.execute_reply.started":"2023-02-09T14:20:17.322481Z","shell.execute_reply":"2023-02-09T14:20:23.345661Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"score","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:23.348091Z","iopub.execute_input":"2023-02-09T14:20:23.348451Z","iopub.status.idle":"2023-02-09T14:20:23.357386Z","shell.execute_reply.started":"2023-02-09T14:20:23.348403Z","shell.execute_reply":"2023-02-09T14:20:23.356073Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:23.35899Z","iopub.execute_input":"2023-02-09T14:20:23.359508Z","iopub.status.idle":"2023-02-09T14:20:23.371814Z","shell.execute_reply.started":"2023-02-09T14:20:23.359459Z","shell.execute_reply":"2023-02-09T14:20:23.370721Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import accuracy_score\nprint(accuracy_score(pred,y_test))","metadata":{"execution":{"iopub.status.busy":"2023-02-09T14:20:23.373162Z","iopub.execute_input":"2023-02-09T14:20:23.374244Z","iopub.status.idle":"2023-02-09T14:20:23.386632Z","shell.execute_reply.started":"2023-02-09T14:20:23.374207Z","shell.execute_reply":"2023-02-09T14:20:23.385171Z"},"trusted":true},"execution_count":null,"outputs":[]}]}