{"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":"2022-08-07T12:31:38.041166Z","iopub.execute_input":"2022-08-07T12:31:38.041510Z","iopub.status.idle":"2022-08-07T12:31:38.076403Z","shell.execute_reply.started":"2022-08-07T12:31:38.041424Z","shell.execute_reply":"2022-08-07T12:31:38.075761Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport seaborn as sns\nfrom xgboost import XGBClassifier\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.linear_model import LogisticRegression","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:40:50.566964Z","iopub.execute_input":"2022-08-07T12:40:50.567279Z","iopub.status.idle":"2022-08-07T12:40:50.572099Z","shell.execute_reply.started":"2022-08-07T12:40:50.567255Z","shell.execute_reply":"2022-08-07T12:40:50.571027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = pd.read_csv(\"/kaggle/input/predict-potential-spammers-on-fiverr/train.csv\")\ntest  = pd.read_csv(\"/kaggle/input/predict-potential-spammers-on-fiverr/test.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:31:40.145987Z","iopub.execute_input":"2022-08-07T12:31:40.146317Z","iopub.status.idle":"2022-08-07T12:31:41.888990Z","shell.execute_reply.started":"2022-08-07T12:31:40.146285Z","shell.execute_reply":"2022-08-07T12:31:41.888039Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:31:41.890579Z","iopub.execute_input":"2022-08-07T12:31:41.890882Z","iopub.status.idle":"2022-08-07T12:31:41.918967Z","shell.execute_reply.started":"2022-08-07T12:31:41.890857Z","shell.execute_reply":"2022-08-07T12:31:41.917729Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cols = [i for i in data.columns if i.startswith(\"X\")]\nprint(cols)","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:31:41.920646Z","iopub.execute_input":"2022-08-07T12:31:41.921058Z","iopub.status.idle":"2022-08-07T12:31:41.926351Z","shell.execute_reply.started":"2022-08-07T12:31:41.921034Z","shell.execute_reply":"2022-08-07T12:31:41.924937Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"constant = []\nfor i in cols:\n    if (data[i].nunique() == 1):\n        constant.append(i)\nprint(constant)","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:31:42.324553Z","iopub.execute_input":"2022-08-07T12:31:42.325417Z","iopub.status.idle":"2022-08-07T12:31:42.461801Z","shell.execute_reply.started":"2022-08-07T12:31:42.325389Z","shell.execute_reply":"2022-08-07T12:31:42.460956Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = data.drop(['X27', 'X29', 'X30', 'X33', 'X46', 'X47', 'X48'],axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:31:42.972353Z","iopub.execute_input":"2022-08-07T12:31:42.972719Z","iopub.status.idle":"2022-08-07T12:31:43.008363Z","shell.execute_reply.started":"2022-08-07T12:31:42.972694Z","shell.execute_reply":"2022-08-07T12:31:43.007115Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:31:43.489035Z","iopub.execute_input":"2022-08-07T12:31:43.489333Z","iopub.status.idle":"2022-08-07T12:31:43.506012Z","shell.execute_reply.started":"2022-08-07T12:31:43.489310Z","shell.execute_reply":"2022-08-07T12:31:43.505189Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y = data['label']\ndata = data.drop(['label','user_id'],axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:31:44.017881Z","iopub.execute_input":"2022-08-07T12:31:44.018888Z","iopub.status.idle":"2022-08-07T12:31:44.050176Z","shell.execute_reply.started":"2022-08-07T12:31:44.018847Z","shell.execute_reply":"2022-08-07T12:31:44.049030Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data['X13'].isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:31:44.459272Z","iopub.execute_input":"2022-08-07T12:31:44.459614Z","iopub.status.idle":"2022-08-07T12:31:44.467879Z","shell.execute_reply.started":"2022-08-07T12:31:44.459588Z","shell.execute_reply":"2022-08-07T12:31:44.466820Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data['X13'].fillna(value=round(data['X13'].median()),inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:31:44.635282Z","iopub.execute_input":"2022-08-07T12:31:44.636595Z","iopub.status.idle":"2022-08-07T12:31:44.648671Z","shell.execute_reply.started":"2022-08-07T12:31:44.636547Z","shell.execute_reply":"2022-08-07T12:31:44.647590Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:31:45.432606Z","iopub.execute_input":"2022-08-07T12:31:45.433930Z","iopub.status.idle":"2022-08-07T12:31:45.441473Z","shell.execute_reply.started":"2022-08-07T12:31:45.433896Z","shell.execute_reply":"2022-08-07T12:31:45.440449Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x =  np.array(data.values)\ny=  np.array(y)","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:31:46.105105Z","iopub.execute_input":"2022-08-07T12:31:46.105420Z","iopub.status.idle":"2022-08-07T12:31:46.167950Z","shell.execute_reply.started":"2022-08-07T12:31:46.105396Z","shell.execute_reply":"2022-08-07T12:31:46.166834Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y[0]","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:40:10.264478Z","iopub.execute_input":"2022-08-07T12:40:10.264786Z","iopub.status.idle":"2022-08-07T12:40:10.272015Z","shell.execute_reply.started":"2022-08-07T12:40:10.264763Z","shell.execute_reply":"2022-08-07T12:40:10.270790Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x[0]","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:31:46.691318Z","iopub.execute_input":"2022-08-07T12:31:46.691827Z","iopub.status.idle":"2022-08-07T12:31:46.701026Z","shell.execute_reply.started":"2022-08-07T12:31:46.691802Z","shell.execute_reply":"2022-08-07T12:31:46.699510Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = XGBClassifier()","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:43:20.591851Z","iopub.execute_input":"2022-08-07T12:43:20.592172Z","iopub.status.idle":"2022-08-07T12:43:20.596839Z","shell.execute_reply.started":"2022-08-07T12:43:20.592147Z","shell.execute_reply":"2022-08-07T12:43:20.595888Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.fit(x,y)\n","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:43:23.666116Z","iopub.execute_input":"2022-08-07T12:43:23.666598Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"user_id  =test['user_id']","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:33:18.018711Z","iopub.execute_input":"2022-08-07T12:33:18.018944Z","iopub.status.idle":"2022-08-07T12:33:18.024453Z","shell.execute_reply.started":"2022-08-07T12:33:18.018923Z","shell.execute_reply":"2022-08-07T12:33:18.023083Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"constant  = []\n\nfor i in test.columns:\n    if (test[i].nunique() ==1 ):\n        constant.append(i)\nconstant","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:33:18.026143Z","iopub.execute_input":"2022-08-07T12:33:18.026488Z","iopub.status.idle":"2022-08-07T12:33:18.053899Z","shell.execute_reply.started":"2022-08-07T12:33:18.026436Z","shell.execute_reply":"2022-08-07T12:33:18.052605Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = test.drop(['X27', 'X29', 'X30', 'X33', 'X46', 'X47', 'X48','user_id'],axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:34:41.206165Z","iopub.execute_input":"2022-08-07T12:34:41.206503Z","iopub.status.idle":"2022-08-07T12:34:41.215008Z","shell.execute_reply.started":"2022-08-07T12:34:41.206477Z","shell.execute_reply":"2022-08-07T12:34:41.213578Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.head()\nlen(test.columns)","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:35:13.854966Z","iopub.execute_input":"2022-08-07T12:35:13.855375Z","iopub.status.idle":"2022-08-07T12:35:13.861706Z","shell.execute_reply.started":"2022-08-07T12:35:13.855342Z","shell.execute_reply":"2022-08-07T12:35:13.860855Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = model.predict(np.array(test.values))","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:41:23.785193Z","iopub.execute_input":"2022-08-07T12:41:23.785578Z","iopub.status.idle":"2022-08-07T12:41:23.798334Z","shell.execute_reply.started":"2022-08-07T12:41:23.785554Z","shell.execute_reply":"2022-08-07T12:41:23.797541Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:34:51.824446Z","iopub.execute_input":"2022-08-07T12:34:51.824786Z","iopub.status.idle":"2022-08-07T12:34:51.831826Z","shell.execute_reply.started":"2022-08-07T12:34:51.824761Z","shell.execute_reply":"2022-08-07T12:34:51.830666Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.DataFrame({\"user_id\":user_id,\"prediction\":predictions})","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:33:18.193153Z","iopub.status.idle":"2022-08-07T12:33:18.193728Z","shell.execute_reply.started":"2022-08-07T12:33:18.193524Z","shell.execute_reply":"2022-08-07T12:33:18.193545Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:33:18.194633Z","iopub.status.idle":"2022-08-07T12:33:18.195680Z","shell.execute_reply.started":"2022-08-07T12:33:18.195489Z","shell.execute_reply":"2022-08-07T12:33:18.195512Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv(\"output3.csv\",index=False)","metadata":{"execution":{"iopub.status.busy":"2022-08-07T12:33:18.196721Z","iopub.status.idle":"2022-08-07T12:33:18.197312Z","shell.execute_reply.started":"2022-08-07T12:33:18.197165Z","shell.execute_reply":"2022-08-07T12:33:18.197180Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}