{"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-07-19T08:02:11.963401Z","iopub.execute_input":"2022-07-19T08:02:11.964338Z","iopub.status.idle":"2022-07-19T08:02:12.000519Z","shell.execute_reply.started":"2022-07-19T08:02:11.964207Z","shell.execute_reply":"2022-07-19T08:02:11.998398Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport seaborn as sb\nimport matplotlib as plt\nfrom sklearn.preprocessing import LabelEncoder\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn.neural_network import MLPClassifier","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:12.029372Z","iopub.execute_input":"2022-07-19T08:02:12.030294Z","iopub.status.idle":"2022-07-19T08:02:13.402194Z","shell.execute_reply.started":"2022-07-19T08:02:12.030250Z","shell.execute_reply":"2022-07-19T08:02:13.401472Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data = pd.read_csv('../input/higgs-boson/training.zip')\ntest_data = pd.read_csv('../input/higgs-boson/test.zip')","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:13.404124Z","iopub.execute_input":"2022-07-19T08:02:13.405205Z","iopub.status.idle":"2022-07-19T08:02:20.218366Z","shell.execute_reply.started":"2022-07-19T08:02:13.405129Z","shell.execute_reply":"2022-07-19T08:02:20.217180Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.shape,test_data.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:20.219478Z","iopub.execute_input":"2022-07-19T08:02:20.219807Z","iopub.status.idle":"2022-07-19T08:02:20.227893Z","shell.execute_reply.started":"2022-07-19T08:02:20.219776Z","shell.execute_reply":"2022-07-19T08:02:20.226996Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:20.229806Z","iopub.execute_input":"2022-07-19T08:02:20.230245Z","iopub.status.idle":"2022-07-19T08:02:20.270763Z","shell.execute_reply.started":"2022-07-19T08:02:20.230214Z","shell.execute_reply":"2022-07-19T08:02:20.269904Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:20.271834Z","iopub.execute_input":"2022-07-19T08:02:20.272152Z","iopub.status.idle":"2022-07-19T08:02:20.303014Z","shell.execute_reply.started":"2022-07-19T08:02:20.272124Z","shell.execute_reply":"2022-07-19T08:02:20.302078Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.columns","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:20.304191Z","iopub.execute_input":"2022-07-19T08:02:20.304517Z","iopub.status.idle":"2022-07-19T08:02:20.310855Z","shell.execute_reply.started":"2022-07-19T08:02:20.304487Z","shell.execute_reply":"2022-07-19T08:02:20.309999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:20.312343Z","iopub.execute_input":"2022-07-19T08:02:20.312753Z","iopub.status.idle":"2022-07-19T08:02:20.385719Z","shell.execute_reply.started":"2022-07-19T08:02:20.312711Z","shell.execute_reply":"2022-07-19T08:02:20.384516Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:20.387168Z","iopub.execute_input":"2022-07-19T08:02:20.387602Z","iopub.status.idle":"2022-07-19T08:02:20.441409Z","shell.execute_reply.started":"2022-07-19T08:02:20.387558Z","shell.execute_reply":"2022-07-19T08:02:20.440575Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:20.442691Z","iopub.execute_input":"2022-07-19T08:02:20.443131Z","iopub.status.idle":"2022-07-19T08:02:20.485311Z","shell.execute_reply.started":"2022-07-19T08:02:20.443087Z","shell.execute_reply":"2022-07-19T08:02:20.484412Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train_data['Label'].value_counts())","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:20.488643Z","iopub.execute_input":"2022-07-19T08:02:20.489009Z","iopub.status.idle":"2022-07-19T08:02:20.524541Z","shell.execute_reply.started":"2022-07-19T08:02:20.488976Z","shell.execute_reply":"2022-07-19T08:02:20.523576Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"enc = LabelEncoder()\n\n\ntrain_data['Label'] = enc.fit_transform(train_data['Label'])\ntrain_data.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:20.525787Z","iopub.execute_input":"2022-07-19T08:02:20.526772Z","iopub.status.idle":"2022-07-19T08:02:20.630103Z","shell.execute_reply.started":"2022-07-19T08:02:20.526739Z","shell.execute_reply":"2022-07-19T08:02:20.629237Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"features = train_data.select_dtypes(include = [np.number])\nfeatures","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:20.631224Z","iopub.execute_input":"2022-07-19T08:02:20.631549Z","iopub.status.idle":"2022-07-19T08:02:20.727765Z","shell.execute_reply.started":"2022-07-19T08:02:20.631519Z","shell.execute_reply":"2022-07-19T08:02:20.726700Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"correlation = features.corr()\nprint(correlation)","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:20.729067Z","iopub.execute_input":"2022-07-19T08:02:20.729423Z","iopub.status.idle":"2022-07-19T08:02:21.543623Z","shell.execute_reply.started":"2022-07-19T08:02:20.729390Z","shell.execute_reply":"2022-07-19T08:02:21.542716Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.drop(['Weight'], axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:21.545098Z","iopub.execute_input":"2022-07-19T08:02:21.545688Z","iopub.status.idle":"2022-07-19T08:02:21.575264Z","shell.execute_reply.started":"2022-07-19T08:02:21.545644Z","shell.execute_reply":"2022-07-19T08:02:21.573668Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:21.576829Z","iopub.execute_input":"2022-07-19T08:02:21.577300Z","iopub.status.idle":"2022-07-19T08:02:21.609964Z","shell.execute_reply.started":"2022-07-19T08:02:21.577239Z","shell.execute_reply":"2022-07-19T08:02:21.609011Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.shape,test_data.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:21.611506Z","iopub.execute_input":"2022-07-19T08:02:21.611839Z","iopub.status.idle":"2022-07-19T08:02:21.618326Z","shell.execute_reply.started":"2022-07-19T08:02:21.611810Z","shell.execute_reply":"2022-07-19T08:02:21.617418Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = train_data.drop(columns = \"Label\")\ny = train_data['Label']","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:21.619241Z","iopub.execute_input":"2022-07-19T08:02:21.619571Z","iopub.status.idle":"2022-07-19T08:02:21.652028Z","shell.execute_reply.started":"2022-07-19T08:02:21.619542Z","shell.execute_reply":"2022-07-19T08:02:21.651194Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X.columns,X.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:21.653361Z","iopub.execute_input":"2022-07-19T08:02:21.653911Z","iopub.status.idle":"2022-07-19T08:02:21.659747Z","shell.execute_reply.started":"2022-07-19T08:02:21.653877Z","shell.execute_reply":"2022-07-19T08:02:21.659005Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:21.661348Z","iopub.execute_input":"2022-07-19T08:02:21.661948Z","iopub.status.idle":"2022-07-19T08:02:21.673498Z","shell.execute_reply.started":"2022-07-19T08:02:21.661875Z","shell.execute_reply":"2022-07-19T08:02:21.672729Z"},"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(X,y,test_size = 0.3)","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:21.674888Z","iopub.execute_input":"2022-07-19T08:02:21.675441Z","iopub.status.idle":"2022-07-19T08:02:21.769820Z","shell.execute_reply.started":"2022-07-19T08:02:21.675408Z","shell.execute_reply":"2022-07-19T08:02:21.769025Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train.shape,X_test.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:21.771182Z","iopub.execute_input":"2022-07-19T08:02:21.771716Z","iopub.status.idle":"2022-07-19T08:02:21.776955Z","shell.execute_reply.started":"2022-07-19T08:02:21.771683Z","shell.execute_reply":"2022-07-19T08:02:21.776160Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **decision tree**","metadata":{}},{"cell_type":"code","source":"from sklearn.tree import DecisionTreeClassifier  \nclassifier_DT= DecisionTreeClassifier(criterion='gini', random_state=0)  \nclassifier_DT.fit(X_train, y_train) ","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:21.778193Z","iopub.execute_input":"2022-07-19T08:02:21.778691Z","iopub.status.idle":"2022-07-19T08:02:33.259131Z","shell.execute_reply.started":"2022-07-19T08:02:21.778654Z","shell.execute_reply":"2022-07-19T08:02:33.258353Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_predict_dt = classifier_DT.predict(X_test) ","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:33.260321Z","iopub.execute_input":"2022-07-19T08:02:33.260852Z","iopub.status.idle":"2022-07-19T08:02:33.303084Z","shell.execute_reply.started":"2022-07-19T08:02:33.260820Z","shell.execute_reply":"2022-07-19T08:02:33.302274Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import accuracy_score,r2_score\nprint(accuracy_score(y_test,y_predict_dt))\nprint(r2_score(y_test,y_predict_dt))","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:33.304337Z","iopub.execute_input":"2022-07-19T08:02:33.304853Z","iopub.status.idle":"2022-07-19T08:02:33.320243Z","shell.execute_reply.started":"2022-07-19T08:02:33.304819Z","shell.execute_reply":"2022-07-19T08:02:33.319356Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_predict_dt_train= classifier_DT.predict(X_train) ","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:33.321479Z","iopub.execute_input":"2022-07-19T08:02:33.322001Z","iopub.status.idle":"2022-07-19T08:02:33.415229Z","shell.execute_reply.started":"2022-07-19T08:02:33.321968Z","shell.execute_reply":"2022-07-19T08:02:33.414287Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(accuracy_score(y_train,y_predict_dt_train))\nprint(r2_score(y_train,y_predict_dt_train))","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:33.416505Z","iopub.execute_input":"2022-07-19T08:02:33.416827Z","iopub.status.idle":"2022-07-19T08:02:33.441751Z","shell.execute_reply.started":"2022-07-19T08:02:33.416799Z","shell.execute_reply":"2022-07-19T08:02:33.440728Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **random forest**\n","metadata":{}},{"cell_type":"code","source":"from sklearn.ensemble import RandomForestClassifier  \nclassifier= RandomForestClassifier(n_estimators= 10, criterion=\"entropy\")  \nclassifier.fit(X_train, y_train)  ","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:33.443443Z","iopub.execute_input":"2022-07-19T08:02:33.443891Z","iopub.status.idle":"2022-07-19T08:02:46.536529Z","shell.execute_reply.started":"2022-07-19T08:02:33.443848Z","shell.execute_reply":"2022-07-19T08:02:46.535096Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_predict_rd = classifier.predict(X_test)  \ny_predict_rd_train = classifier.predict(X_train) ","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:46.542531Z","iopub.execute_input":"2022-07-19T08:02:46.542919Z","iopub.status.idle":"2022-07-19T08:02:47.413407Z","shell.execute_reply.started":"2022-07-19T08:02:46.542883Z","shell.execute_reply":"2022-07-19T08:02:47.412374Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(accuracy_score(y_test,y_predict_rd))\nprint(accuracy_score(y_train,y_predict_rd_train))\n","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:47.414880Z","iopub.execute_input":"2022-07-19T08:02:47.415369Z","iopub.status.idle":"2022-07-19T08:02:47.449136Z","shell.execute_reply.started":"2022-07-19T08:02:47.415322Z","shell.execute_reply":"2022-07-19T08:02:47.448193Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.neural_network import MLPClassifier\nfrom sklearn.datasets import make_classification\nfrom sklearn.model_selection import train_test_split","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:47.450301Z","iopub.execute_input":"2022-07-19T08:02:47.450851Z","iopub.status.idle":"2022-07-19T08:02:47.527079Z","shell.execute_reply.started":"2022-07-19T08:02:47.450817Z","shell.execute_reply":"2022-07-19T08:02:47.526160Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"'''X, y = make_classification(n_samples=10, random_state=1)\nX_train, X_test, y_train, y_test = train_test_split(X, y, stratify=y,\n                                                    random_state=1)'''\nclf = MLPClassifier(random_state=1, max_iter=300)","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:47.528413Z","iopub.execute_input":"2022-07-19T08:02:47.529178Z","iopub.status.idle":"2022-07-19T08:02:47.534251Z","shell.execute_reply.started":"2022-07-19T08:02:47.529143Z","shell.execute_reply":"2022-07-19T08:02:47.533250Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"clf.fit(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:02:47.535585Z","iopub.execute_input":"2022-07-19T08:02:47.536241Z","iopub.status.idle":"2022-07-19T08:05:35.073078Z","shell.execute_reply.started":"2022-07-19T08:02:47.536206Z","shell.execute_reply":"2022-07-19T08:05:35.072116Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"clf = MLPClassifier(random_state=1, max_iter=300).fit(X_train, y_train)\nclf.predict_proba(X_test[:1])","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:05:35.074397Z","iopub.execute_input":"2022-07-19T08:05:35.075088Z","iopub.status.idle":"2022-07-19T08:08:18.907521Z","shell.execute_reply.started":"2022-07-19T08:05:35.075042Z","shell.execute_reply":"2022-07-19T08:08:18.906467Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"clf_predict = clf.predict(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:18.909392Z","iopub.execute_input":"2022-07-19T08:08:18.910619Z","iopub.status.idle":"2022-07-19T08:08:19.643969Z","shell.execute_reply.started":"2022-07-19T08:08:18.910563Z","shell.execute_reply":"2022-07-19T08:08:19.642853Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"clf_predict_train = clf.predict(X_train)","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:19.646129Z","iopub.execute_input":"2022-07-19T08:08:19.647066Z","iopub.status.idle":"2022-07-19T08:08:21.091556Z","shell.execute_reply.started":"2022-07-19T08:08:19.647007Z","shell.execute_reply":"2022-07-19T08:08:21.090440Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(accuracy_score(y_test, clf_predict))\nprint(accuracy_score(y_train, clf_predict_train))","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:21.093594Z","iopub.execute_input":"2022-07-19T08:08:21.094476Z","iopub.status.idle":"2022-07-19T08:08:21.144841Z","shell.execute_reply.started":"2022-07-19T08:08:21.094422Z","shell.execute_reply":"2022-07-19T08:08:21.143800Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Deployment**","metadata":{}},{"cell_type":"code","source":"pip install gradio","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:21.146875Z","iopub.execute_input":"2022-07-19T08:08:21.147763Z","iopub.status.idle":"2022-07-19T08:08:43.301594Z","shell.execute_reply.started":"2022-07-19T08:08:21.147709Z","shell.execute_reply":"2022-07-19T08:08:43.300369Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import gradio as gr","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:43.303262Z","iopub.execute_input":"2022-07-19T08:08:43.303658Z","iopub.status.idle":"2022-07-19T08:08:44.708272Z","shell.execute_reply.started":"2022-07-19T08:08:43.303619Z","shell.execute_reply":"2022-07-19T08:08:44.707394Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"train_data.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:44.709755Z","iopub.execute_input":"2022-07-19T08:08:44.710584Z","iopub.status.idle":"2022-07-19T08:08:44.717586Z","shell.execute_reply.started":"2022-07-19T08:08:44.710544Z","shell.execute_reply":"2022-07-19T08:08:44.716200Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train_data.columns)","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:44.718899Z","iopub.execute_input":"2022-07-19T08:08:44.719396Z","iopub.status.idle":"2022-07-19T08:08:44.732740Z","shell.execute_reply.started":"2022-07-19T08:08:44.719351Z","shell.execute_reply":"2022-07-19T08:08:44.732068Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.index.name = \"index\"","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:44.733957Z","iopub.execute_input":"2022-07-19T08:08:44.734461Z","iopub.status.idle":"2022-07-19T08:08:44.743394Z","shell.execute_reply.started":"2022-07-19T08:08:44.734421Z","shell.execute_reply":"2022-07-19T08:08:44.742626Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"index = [x for x in range(1, 250001)]","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:44.744566Z","iopub.execute_input":"2022-07-19T08:08:44.744964Z","iopub.status.idle":"2022-07-19T08:08:44.768293Z","shell.execute_reply.started":"2022-07-19T08:08:44.744910Z","shell.execute_reply":"2022-07-19T08:08:44.767469Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.index = index","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:44.769393Z","iopub.execute_input":"2022-07-19T08:08:44.769852Z","iopub.status.idle":"2022-07-19T08:08:44.873083Z","shell.execute_reply.started":"2022-07-19T08:08:44.769820Z","shell.execute_reply":"2022-07-19T08:08:44.872013Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pickle","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:44.874352Z","iopub.execute_input":"2022-07-19T08:08:44.874740Z","iopub.status.idle":"2022-07-19T08:08:44.879414Z","shell.execute_reply.started":"2022-07-19T08:08:44.874697Z","shell.execute_reply":"2022-07-19T08:08:44.878353Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pickle.dump(clf,open('csv.sav','wb'))","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:44.880718Z","iopub.execute_input":"2022-07-19T08:08:44.881179Z","iopub.status.idle":"2022-07-19T08:08:44.892160Z","shell.execute_reply.started":"2022-07-19T08:08:44.881135Z","shell.execute_reply":"2022-07-19T08:08:44.890939Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = pickle.load(open('csv.sav','rb'))","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:44.893759Z","iopub.execute_input":"2022-07-19T08:08:44.894538Z","iopub.status.idle":"2022-07-19T08:08:44.908864Z","shell.execute_reply.started":"2022-07-19T08:08:44.894487Z","shell.execute_reply":"2022-07-19T08:08:44.908023Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def predict_res(RankOrder,EventId):\n    #x = train_data.loc[RankOrder].to_numpy()\n    #a_stand = (x-X_train_data.mean())/(X_train_data.std())\n    preds = model.predict([[RankOrder,EventId]])\n    if preds == 0:\n        return \"0\"\n    else:\n        return \"1\"\n    \n        ","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:44.910522Z","iopub.execute_input":"2022-07-19T08:08:44.911295Z","iopub.status.idle":"2022-07-19T08:08:44.921323Z","shell.execute_reply.started":"2022-07-19T08:08:44.911250Z","shell.execute_reply":"2022-07-19T08:08:44.920172Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"title = \"Label\"\ndescription = \"\"\"\n<center>\nprediction of label\n</center>\n\"\"\"","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:44.922702Z","iopub.execute_input":"2022-07-19T08:08:44.923644Z","iopub.status.idle":"2022-07-19T08:08:44.932905Z","shell.execute_reply.started":"2022-07-19T08:08:44.923591Z","shell.execute_reply":"2022-07-19T08:08:44.932017Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"outputs = gr.outputs.Textbox()","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:44.934480Z","iopub.execute_input":"2022-07-19T08:08:44.934982Z","iopub.status.idle":"2022-07-19T08:08:44.948176Z","shell.execute_reply.started":"2022-07-19T08:08:44.934907Z","shell.execute_reply":"2022-07-19T08:08:44.947016Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"gr.Interface(fn = predict_res, inputs=\"number\", outputs=\"number\",title = title,description = description).launch(share = True)","metadata":{"execution":{"iopub.status.busy":"2022-07-19T08:08:44.949347Z","iopub.execute_input":"2022-07-19T08:08:44.949653Z","iopub.status.idle":"2022-07-19T08:08:47.909821Z","shell.execute_reply.started":"2022-07-19T08:08:44.949625Z","shell.execute_reply":"2022-07-19T08:08:47.908796Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}