{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":84493,"databundleVersionId":9871156,"sourceType":"competition"},{"sourceId":217281771,"sourceType":"kernelVersion"},{"sourceId":227574,"sourceType":"modelInstanceVersion","isSourceIdPinned":true,"modelInstanceId":194023,"modelId":215940}],"dockerImageVersionId":30822,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"***We will write a model for market forecasting in Jane Street first, we call the libraries.***","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport seaborn as sns\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.metrics import roc_auc_score , roc_curve \nfrom sklearn.linear_model import LinearRegression\nimport warnings\nwarnings.filterwarnings('ignore')","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-01-12T15:57:57.565902Z","iopub.execute_input":"2025-01-12T15:57:57.566347Z","iopub.status.idle":"2025-01-12T15:57:57.572719Z","shell.execute_reply.started":"2025-01-12T15:57:57.566309Z","shell.execute_reply":"2025-01-12T15:57:57.571523Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"***We also read and display the file.***","metadata":{}},{"cell_type":"code","source":"responders = pd.read_csv('../input/jane-street-real-time-market-data-forecasting/responders.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-12T15:58:00.499779Z","iopub.execute_input":"2025-01-12T15:58:00.500152Z","iopub.status.idle":"2025-01-12T15:58:00.506886Z","shell.execute_reply.started":"2025-01-12T15:58:00.500122Z","shell.execute_reply":"2025-01-12T15:58:00.505868Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"responders.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-12T15:58:03.809022Z","iopub.execute_input":"2025-01-12T15:58:03.809349Z","iopub.status.idle":"2025-01-12T15:58:03.820030Z","shell.execute_reply.started":"2025-01-12T15:58:03.809323Z","shell.execute_reply":"2025-01-12T15:58:03.819062Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"***Here we make sure that the file is complete.***","metadata":{}},{"cell_type":"code","source":"responders.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-12T15:58:09.384532Z","iopub.execute_input":"2025-01-12T15:58:09.384919Z","iopub.status.idle":"2025-01-12T15:58:09.412941Z","shell.execute_reply.started":"2025-01-12T15:58:09.384892Z","shell.execute_reply":"2025-01-12T15:58:09.411985Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"responders.describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-12T15:58:12.665787Z","iopub.execute_input":"2025-01-12T15:58:12.666122Z","iopub.status.idle":"2025-01-12T15:58:12.687792Z","shell.execute_reply.started":"2025-01-12T15:58:12.666097Z","shell.execute_reply":"2025-01-12T15:58:12.686666Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"***We delete a responder column from the file and display it again.***","metadata":{}},{"cell_type":"code","source":"responders_new = responders.drop(columns=['responder'])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-12T15:58:16.711053Z","iopub.execute_input":"2025-01-12T15:58:16.711367Z","iopub.status.idle":"2025-01-12T15:58:16.718728Z","shell.execute_reply.started":"2025-01-12T15:58:16.711342Z","shell.execute_reply":"2025-01-12T15:58:16.717737Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"responders_new.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-12T15:58:20.356847Z","iopub.execute_input":"2025-01-12T15:58:20.357173Z","iopub.status.idle":"2025-01-12T15:58:20.367831Z","shell.execute_reply.started":"2025-01-12T15:58:20.357149Z","shell.execute_reply":"2025-01-12T15:58:20.366720Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"***Then we discover the vertical relationship with each other.***","metadata":{}},{"cell_type":"markdown","source":"responders_new.corr()","metadata":{"execution":{"iopub.status.busy":"2025-01-12T03:17:05.176815Z","iopub.execute_input":"2025-01-12T03:17:05.177439Z","iopub.status.idle":"2025-01-12T03:17:05.207203Z","shell.execute_reply.started":"2025-01-12T03:17:05.177390Z","shell.execute_reply":"2025-01-12T03:17:05.205838Z"}}},{"cell_type":"code","source":"sns.heatmap(responders_new.corr(), annot=True,fmt='0.1f')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-12T15:58:24.674598Z","iopub.execute_input":"2025-01-12T15:58:24.674980Z","iopub.status.idle":"2025-01-12T15:58:25.076720Z","shell.execute_reply.started":"2025-01-12T15:58:24.674945Z","shell.execute_reply":"2025-01-12T15:58:25.075531Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"We mention the number of times it is wrong and right in each column","metadata":{}},{"cell_type":"code","source":"for column in responders_new.columns:\n    sns.countplot(x=column, data=responders_new)\n    plt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-12T15:58:29.513442Z","iopub.execute_input":"2025-01-12T15:58:29.513805Z","iopub.status.idle":"2025-01-12T15:58:30.410334Z","shell.execute_reply.started":"2025-01-12T15:58:29.513777Z","shell.execute_reply":"2025-01-12T15:58:30.409374Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"model \n***We build a model using the LinearRegression library and trian_test _split and display the results using the roc_auc_score ***","metadata":{}},{"cell_type":"code","source":"x = responders_new.drop(columns=['tag_0'])\ny = responders_new['tag_0']","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-12T15:58:36.760335Z","iopub.execute_input":"2025-01-12T15:58:36.760857Z","iopub.status.idle":"2025-01-12T15:58:36.767125Z","shell.execute_reply.started":"2025-01-12T15:58:36.760806Z","shell.execute_reply":"2025-01-12T15:58:36.765906Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=2)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-12T15:58:39.134835Z","iopub.execute_input":"2025-01-12T15:58:39.135293Z","iopub.status.idle":"2025-01-12T15:58:39.146841Z","shell.execute_reply.started":"2025-01-12T15:58:39.135254Z","shell.execute_reply":"2025-01-12T15:58:39.145704Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model = LinearRegression()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-12T15:58:42.141154Z","iopub.execute_input":"2025-01-12T15:58:42.141530Z","iopub.status.idle":"2025-01-12T15:58:42.145802Z","shell.execute_reply.started":"2025-01-12T15:58:42.141497Z","shell.execute_reply":"2025-01-12T15:58:42.144641Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.fit(x_train, y_train)  \npre = model.predict(x_test)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-12T15:58:44.731986Z","iopub.execute_input":"2025-01-12T15:58:44.732315Z","iopub.status.idle":"2025-01-12T15:58:44.761965Z","shell.execute_reply.started":"2025-01-12T15:58:44.732290Z","shell.execute_reply":"2025-01-12T15:58:44.760873Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pre=model.predict(x_test)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-12T15:58:48.324184Z","iopub.execute_input":"2025-01-12T15:58:48.324603Z","iopub.status.idle":"2025-01-12T15:58:48.330526Z","shell.execute_reply.started":"2025-01-12T15:58:48.324563Z","shell.execute_reply":"2025-01-12T15:58:48.329436Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"roc_score=  roc_auc_score(y_test,pre)\nr_c=  roc_curve(y_test,pre)\nprint(model)\nprint('roc_ is :',roc_score)\ndf = pd.DataFrame(r_c)\nsns.heatmap(df)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2025-01-12T15:58:50.748918Z","iopub.execute_input":"2025-01-12T15:58:50.749234Z","iopub.status.idle":"2025-01-12T15:58:51.021319Z","shell.execute_reply.started":"2025-01-12T15:58:50.749210Z","shell.execute_reply":"2025-01-12T15:58:51.020234Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"***Thank you all***","metadata":{}},{"cell_type":"markdown","source":"","metadata":{}}]}