{"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-10T07:27:39.340991Z","iopub.execute_input":"2022-08-10T07:27:39.341769Z","iopub.status.idle":"2022-08-10T07:27:39.375446Z","shell.execute_reply.started":"2022-08-10T07:27:39.341664Z","shell.execute_reply":"2022-08-10T07:27:39.374247Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\n%matplotlib inline\n\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2022-08-10T07:28:31.312313Z","iopub.execute_input":"2022-08-10T07:28:31.312760Z","iopub.status.idle":"2022-08-10T07:28:31.984778Z","shell.execute_reply.started":"2022-08-10T07:28:31.312711Z","shell.execute_reply":"2022-08-10T07:28:31.983242Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train=pd.read_csv('/kaggle/input/new-york-city-taxi-fare-prediction/train.csv', nrows=2000000, parse_dates=['pickup_datetime'])","metadata":{"execution":{"iopub.status.busy":"2022-08-10T07:29:40.512209Z","iopub.execute_input":"2022-08-10T07:29:40.512690Z","iopub.status.idle":"2022-08-10T07:34:55.780494Z","shell.execute_reply.started":"2022-08-10T07:29:40.512653Z","shell.execute_reply":"2022-08-10T07:34:55.779466Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T07:40:52.790262Z","iopub.execute_input":"2022-08-10T07:40:52.790780Z","iopub.status.idle":"2022-08-10T07:40:52.833636Z","shell.execute_reply.started":"2022-08-10T07:40:52.790727Z","shell.execute_reply":"2022-08-10T07:40:52.832334Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.describe()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T07:42:13.131084Z","iopub.execute_input":"2022-08-10T07:42:13.131598Z","iopub.status.idle":"2022-08-10T07:42:13.779393Z","shell.execute_reply.started":"2022-08-10T07:42:13.131560Z","shell.execute_reply":"2022-08-10T07:42:13.777908Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#negative fare amount values should be dropped\n#passenger count of zero should be dropped\n#new york city coordinates are lat40.730610 and long -73.935242 so coordinates way out of the range should be dropped\n#minimum fare amount in new york is 2.5 so values less than that should be dropped","metadata":{"execution":{"iopub.status.busy":"2022-08-10T07:45:43.101689Z","iopub.execute_input":"2022-08-10T07:45:43.102176Z","iopub.status.idle":"2022-08-10T07:45:43.107833Z","shell.execute_reply.started":"2022-08-10T07:45:43.102138Z","shell.execute_reply":"2022-08-10T07:45:43.106202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train=train.loc[train['pickup_latitude'].between(40,42)]\ntrain=train.loc[train['pickup_longitude'].between(-75,-72)]\ntrain=train.loc[train['dropoff_latitude'].between(40,42)]\ntrain=train.loc[train['dropoff_longitude'].between(-75,-72)]\ntrain=train.loc[train['fare_amount']>=2.5]\ntrain=train.loc[train['passenger_count']>0]","metadata":{"execution":{"iopub.status.busy":"2022-08-10T07:51:29.991248Z","iopub.execute_input":"2022-08-10T07:51:29.991709Z","iopub.status.idle":"2022-08-10T07:51:30.772449Z","shell.execute_reply.started":"2022-08-10T07:51:29.991669Z","shell.execute_reply":"2022-08-10T07:51:30.771442Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train.isnull().sum())","metadata":{"execution":{"iopub.status.busy":"2022-08-10T07:54:20.361741Z","iopub.execute_input":"2022-08-10T07:54:20.362198Z","iopub.status.idle":"2022-08-10T07:54:20.494518Z","shell.execute_reply.started":"2022-08-10T07:54:20.362162Z","shell.execute_reply":"2022-08-10T07:54:20.493176Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(14,4))\nplt.hist(train['fare_amount'],1000, facecolor='red')\nplt.xlabel('fare amount')\nplt.ylabel('count')\nplt.title('histogram of fare amount')\nplt.xlim(0,100)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:05:21.096990Z","iopub.execute_input":"2022-08-10T08:05:21.097441Z","iopub.status.idle":"2022-08-10T08:05:24.492869Z","shell.execute_reply.started":"2022-08-10T08:05:21.097405Z","shell.execute_reply":"2022-08-10T08:05:24.491490Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train['passenger_count'].value_counts().plot.bar()\nplt.title('histgoram of passenger count')\nplt.xlabel('passenger count')\nplt.ylabel('frequency')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:12:58.543724Z","iopub.execute_input":"2022-08-10T08:12:58.545577Z","iopub.status.idle":"2022-08-10T08:12:58.750195Z","shell.execute_reply.started":"2022-08-10T08:12:58.545498Z","shell.execute_reply":"2022-08-10T08:12:58.748829Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#removing outliers\ntrain=train.loc[train['passenger_count']<=6]","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:21:42.702800Z","iopub.execute_input":"2022-08-10T08:21:42.703281Z","iopub.status.idle":"2022-08-10T08:21:42.861265Z","shell.execute_reply.started":"2022-08-10T08:21:42.703243Z","shell.execute_reply":"2022-08-10T08:21:42.859955Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import folium","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:21:51.884240Z","iopub.execute_input":"2022-08-10T08:21:51.884683Z","iopub.status.idle":"2022-08-10T08:21:52.128261Z","shell.execute_reply.started":"2022-08-10T08:21:51.884646Z","shell.execute_reply":"2022-08-10T08:21:52.127044Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_york=folium.Map(location=[40.730610, -73.935242], zoom_start=12)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:23:57.247036Z","iopub.execute_input":"2022-08-10T08:23:57.247467Z","iopub.status.idle":"2022-08-10T08:23:57.265402Z","shell.execute_reply.started":"2022-08-10T08:23:57.247433Z","shell.execute_reply":"2022-08-10T08:23:57.264170Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_york","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:24:03.139617Z","iopub.execute_input":"2022-08-10T08:24:03.140016Z","iopub.status.idle":"2022-08-10T08:24:03.154070Z","shell.execute_reply.started":"2022-08-10T08:24:03.139985Z","shell.execute_reply":"2022-08-10T08:24:03.152600Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in train.index[:100]:\n    folium.CircleMarker(location=[train['pickup_latitude'][i],train['pickup_longitude'][i]],color='red').add_to(new_york)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:29:06.640496Z","iopub.execute_input":"2022-08-10T08:29:06.640936Z","iopub.status.idle":"2022-08-10T08:29:06.662114Z","shell.execute_reply.started":"2022-08-10T08:29:06.640892Z","shell.execute_reply":"2022-08-10T08:29:06.660908Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in train.index[:100]:\n    folium.CircleMarker(location=[train['dropoff_latitude'][i],train['dropoff_longitude'][i]],color='blue').add_to(new_york)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:31:37.431048Z","iopub.execute_input":"2022-08-10T08:31:37.431541Z","iopub.status.idle":"2022-08-10T08:31:37.446775Z","shell.execute_reply.started":"2022-08-10T08:31:37.431488Z","shell.execute_reply":"2022-08-10T08:31:37.445437Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_york","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:31:43.231889Z","iopub.execute_input":"2022-08-10T08:31:43.232408Z","iopub.status.idle":"2022-08-10T08:31:43.384963Z","shell.execute_reply.started":"2022-08-10T08:31:43.232280Z","shell.execute_reply":"2022-08-10T08:31:43.383597Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#pickups and dropoffs are mostly in the same area","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:36:25.040595Z","iopub.execute_input":"2022-08-10T08:36:25.041077Z","iopub.status.idle":"2022-08-10T08:36:25.047260Z","shell.execute_reply.started":"2022-08-10T08:36:25.041041Z","shell.execute_reply":"2022-08-10T08:36:25.045926Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Feature Engineering","metadata":{}},{"cell_type":"code","source":"train['year']=train.pickup_datetime.dt.year\ntrain['month']=train.pickup_datetime.dt.month\ntrain['day']=train.pickup_datetime.dt.day\ntrain['weekday']=train.pickup_datetime.dt.weekday\ntrain['hour']=train.pickup_datetime.dt.hour ","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:41:14.460416Z","iopub.execute_input":"2022-08-10T08:41:14.460839Z","iopub.status.idle":"2022-08-10T08:41:15.657006Z","shell.execute_reply.started":"2022-08-10T08:41:14.460802Z","shell.execute_reply":"2022-08-10T08:41:15.655788Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:42:22.135168Z","iopub.execute_input":"2022-08-10T08:42:22.136236Z","iopub.status.idle":"2022-08-10T08:42:22.156868Z","shell.execute_reply.started":"2022-08-10T08:42:22.136194Z","shell.execute_reply":"2022-08-10T08:42:22.155199Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def distance(lat1, lon1, lat2, lon2):\n    p=0.0174532925199432295\n    a=0.5-np.cos((lat2-lat1)*p)/2 + np.cos(lat1*p)*np.cos(lat2*p)*(1-np.cos((lon2-lon1)*p))/2\n    return 12742*np.arcsin(np.sqrt(a))\n\ntrain['distance']=distance(train.pickup_latitude, train.pickup_longitude,  \n                                 train.dropoff_latitude, train.dropoff_longitude)\n\ntrain.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T08:57:41.272924Z","iopub.execute_input":"2022-08-10T08:57:41.273813Z","iopub.status.idle":"2022-08-10T08:57:41.440783Z","shell.execute_reply.started":"2022-08-10T08:57:41.273767Z","shell.execute_reply":"2022-08-10T08:57:41.439522Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(14,4))\nsns.displot(train['distance'], bins=1000, color='green', kde=False)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T09:01:47.779176Z","iopub.execute_input":"2022-08-10T09:01:47.779667Z","iopub.status.idle":"2022-08-10T09:01:51.404247Z","shell.execute_reply.started":"2022-08-10T09:01:47.779626Z","shell.execute_reply":"2022-08-10T09:01:51.402772Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#distance can't be 0 so I'll drop zeros\ntrain=train.loc[train['distance']>0]","metadata":{"execution":{"iopub.status.busy":"2022-08-10T09:05:00.551788Z","iopub.execute_input":"2022-08-10T09:05:00.552198Z","iopub.status.idle":"2022-08-10T09:05:00.748004Z","shell.execute_reply.started":"2022-08-10T09:05:00.552162Z","shell.execute_reply":"2022-08-10T09:05:00.746623Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Tuning","metadata":{}},{"cell_type":"code","source":"del train['pickup_datetime']\ndel train['key']","metadata":{"execution":{"iopub.status.busy":"2022-08-10T09:08:00.628311Z","iopub.execute_input":"2022-08-10T09:08:00.628814Z","iopub.status.idle":"2022-08-10T09:08:00.661076Z","shell.execute_reply.started":"2022-08-10T09:08:00.628776Z","shell.execute_reply":"2022-08-10T09:08:00.659693Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split","metadata":{"execution":{"iopub.status.busy":"2022-08-10T09:08:30.851633Z","iopub.execute_input":"2022-08-10T09:08:30.852046Z","iopub.status.idle":"2022-08-10T09:08:30.953230Z","shell.execute_reply.started":"2022-08-10T09:08:30.852013Z","shell.execute_reply":"2022-08-10T09:08:30.952216Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y=train['fare_amount']\nX=train.drop(columns=['fare_amount'])\nX_train, X_test, y_train, y_test=train_test_split(X,y, test_size=0.3, random_state=50)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T09:12:31.793536Z","iopub.execute_input":"2022-08-10T09:12:31.793941Z","iopub.status.idle":"2022-08-10T09:12:32.439644Z","shell.execute_reply.started":"2022-08-10T09:12:31.793908Z","shell.execute_reply":"2022-08-10T09:12:32.438556Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Linear regression model","metadata":{}},{"cell_type":"code","source":"from sklearn.linear_model import LinearRegression\n\nlr=LinearRegression()\nlr.fit(X_train, y_train)\ny_pred=lr.predict(X_test)\n\nfrom sklearn.metrics import mean_squared_error\n\nprint(mean_squared_error(y_test, y_pred)**0.5) #RMSE","metadata":{"execution":{"iopub.status.busy":"2022-08-10T09:31:27.036234Z","iopub.execute_input":"2022-08-10T09:31:27.036696Z","iopub.status.idle":"2022-08-10T09:31:27.652051Z","shell.execute_reply.started":"2022-08-10T09:31:27.036657Z","shell.execute_reply":"2022-08-10T09:31:27.650382Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Random forest","metadata":{}},{"cell_type":"code","source":"from sklearn.ensemble import RandomForestRegressor\n\nrf=RandomForestRegressor(max_depth=2, random_state=0, n_estimators=100)\nrf.fit(X_train, y_train)\ny_pred=rf.predict(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T09:43:10.959259Z","iopub.execute_input":"2022-08-10T09:43:10.959707Z","iopub.status.idle":"2022-08-10T09:46:24.212149Z","shell.execute_reply.started":"2022-08-10T09:43:10.959669Z","shell.execute_reply":"2022-08-10T09:46:24.210644Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(mean_squared_error(y_test, y_pred)**0.5) #RMSE","metadata":{"execution":{"iopub.status.busy":"2022-08-10T09:46:59.274824Z","iopub.execute_input":"2022-08-10T09:46:59.275266Z","iopub.status.idle":"2022-08-10T09:46:59.286937Z","shell.execute_reply.started":"2022-08-10T09:46:59.275228Z","shell.execute_reply":"2022-08-10T09:46:59.285748Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"LightGBM","metadata":{}},{"cell_type":"code","source":"import lightgbm as lgb","metadata":{"execution":{"iopub.status.busy":"2022-08-10T09:48:15.892388Z","iopub.execute_input":"2022-08-10T09:48:15.892890Z","iopub.status.idle":"2022-08-10T09:48:17.032895Z","shell.execute_reply.started":"2022-08-10T09:48:15.892843Z","shell.execute_reply":"2022-08-10T09:48:17.031603Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"parameters= {\n    'learning rate': 0.75,\n    'application':'regression',\n    'max_depth': 3,\n    'num_leaves': 100,\n    'verbosity': -1,\n    'metric': 'RMSE'}\n    ","metadata":{"execution":{"iopub.status.busy":"2022-08-10T09:53:40.536042Z","iopub.execute_input":"2022-08-10T09:53:40.536750Z","iopub.status.idle":"2022-08-10T09:53:40.544268Z","shell.execute_reply.started":"2022-08-10T09:53:40.536702Z","shell.execute_reply":"2022-08-10T09:53:40.542422Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_set=lgb.Dataset(X_train, y_train, silent=True)\nlb=lgb.train(parameters, train_set=train_set)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T09:56:25.591104Z","iopub.execute_input":"2022-08-10T09:56:25.591622Z","iopub.status.idle":"2022-08-10T09:56:31.168299Z","shell.execute_reply.started":"2022-08-10T09:56:25.591583Z","shell.execute_reply":"2022-08-10T09:56:31.166186Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred=lb.predict(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T09:57:18.677868Z","iopub.execute_input":"2022-08-10T09:57:18.678354Z","iopub.status.idle":"2022-08-10T09:57:19.650585Z","shell.execute_reply.started":"2022-08-10T09:57:18.678281Z","shell.execute_reply":"2022-08-10T09:57:19.649591Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(mean_squared_error(y_test, y_pred)**0.5) #RMSE","metadata":{"execution":{"iopub.status.busy":"2022-08-10T09:58:44.641169Z","iopub.execute_input":"2022-08-10T09:58:44.641780Z","iopub.status.idle":"2022-08-10T09:58:44.652311Z","shell.execute_reply.started":"2022-08-10T09:58:44.641733Z","shell.execute_reply":"2022-08-10T09:58:44.651118Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"lightBGM model performed the best","metadata":{}},{"cell_type":"code","source":"test = pd.read_csv('/kaggle/input/new-york-city-taxi-fare-prediction/test.csv', parse_dates=['pickup_datetime'])","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:02:14.376552Z","iopub.execute_input":"2022-08-10T10:02:14.377063Z","iopub.status.idle":"2022-08-10T10:02:14.735959Z","shell.execute_reply.started":"2022-08-10T10:02:14.377022Z","shell.execute_reply":"2022-08-10T10:02:14.733975Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:02:29.792150Z","iopub.execute_input":"2022-08-10T10:02:29.792578Z","iopub.status.idle":"2022-08-10T10:02:29.813175Z","shell.execute_reply.started":"2022-08-10T10:02:29.792538Z","shell.execute_reply":"2022-08-10T10:02:29.811911Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test['year']=test.pickup_datetime.dt.year\ntest['month']=test.pickup_datetime.dt.month\ntest['day']=test.pickup_datetime.dt.day\ntest['weekday']=test.pickup_datetime.dt.weekday\ntest['hour']=test.pickup_datetime.dt.hour","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:04:11.729500Z","iopub.execute_input":"2022-08-10T10:04:11.730015Z","iopub.status.idle":"2022-08-10T10:04:11.752061Z","shell.execute_reply.started":"2022-08-10T10:04:11.729974Z","shell.execute_reply":"2022-08-10T10:04:11.751121Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test['distance']=distance(test.pickup_latitude, test.pickup_longitude,  \n                                 test.dropoff_latitude, test.dropoff_longitude)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:04:53.373649Z","iopub.execute_input":"2022-08-10T10:04:53.374058Z","iopub.status.idle":"2022-08-10T10:04:53.385578Z","shell.execute_reply.started":"2022-08-10T10:04:53.374025Z","shell.execute_reply":"2022-08-10T10:04:53.384476Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:04:58.127935Z","iopub.execute_input":"2022-08-10T10:04:58.128594Z","iopub.status.idle":"2022-08-10T10:04:58.152658Z","shell.execute_reply.started":"2022-08-10T10:04:58.128546Z","shell.execute_reply":"2022-08-10T10:04:58.151317Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_test=test.drop([\"key\", \"pickup_datetime\"], axis=1)\npredictions=lb.predict(x_test)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:19:48.145157Z","iopub.execute_input":"2022-08-10T10:19:48.145763Z","iopub.status.idle":"2022-08-10T10:19:48.177945Z","shell.execute_reply.started":"2022-08-10T10:19:48.145723Z","shell.execute_reply":"2022-08-10T10:19:48.176742Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_keys = test[\"key\"]\n\ndataframe = pd.DataFrame({\"key\":test_keys.values,\n                         \"fare_amount\": predictions})","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:22:39.698985Z","iopub.execute_input":"2022-08-10T10:22:39.699467Z","iopub.status.idle":"2022-08-10T10:22:39.708119Z","shell.execute_reply.started":"2022-08-10T10:22:39.699431Z","shell.execute_reply":"2022-08-10T10:22:39.706561Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataframe.to_csv(\"submission.csv\", index = False)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:23:47.143089Z","iopub.execute_input":"2022-08-10T10:23:47.143618Z","iopub.status.idle":"2022-08-10T10:23:47.183867Z","shell.execute_reply.started":"2022-08-10T10:23:47.143576Z","shell.execute_reply":"2022-08-10T10:23:47.182866Z"},"trusted":true},"execution_count":null,"outputs":[]}]}