|
101 | 101 | "cell_type": "markdown", |
102 | 102 | "metadata": {}, |
103 | 103 | "source": [ |
104 | | - "Now that the initial data is loaded, define a function to create various time-based features from the pickup datetime field. This will create new fields for the month number, day of month, day of week, and hour of day, and will allow the model to factor in time-based seasonality. \n", |
105 | | - "\n", |
106 | | - "Use the `apply()` function on the dataframe to iteratively apply the `build_time_features()` function to each row in the taxi data." |
107 | | - ] |
108 | | - }, |
109 | | - { |
110 | | - "cell_type": "code", |
111 | | - "execution_count": null, |
112 | | - "metadata": {}, |
113 | | - "outputs": [], |
114 | | - "source": [ |
115 | | - "def build_time_features(vector):\n", |
116 | | - " pickup_datetime = vector[0]\n", |
117 | | - " month_num = pickup_datetime.month\n", |
118 | | - " day_of_month = pickup_datetime.day\n", |
119 | | - " day_of_week = pickup_datetime.weekday()\n", |
120 | | - " hour_of_day = pickup_datetime.hour\n", |
121 | | - " \n", |
122 | | - " return pd.Series((month_num, day_of_month, day_of_week, hour_of_day))\n", |
123 | | - "\n", |
124 | | - "green_taxi_df[[\"month_num\", \"day_of_month\",\"day_of_week\", \"hour_of_day\"]] = green_taxi_df[[\"lpepPickupDatetime\"]].apply(build_time_features, axis=1)\n", |
125 | | - "green_taxi_df.head(10)" |
126 | | - ] |
127 | | - }, |
128 | | - { |
129 | | - "cell_type": "markdown", |
130 | | - "metadata": {}, |
131 | | - "source": [ |
132 | | - "Remove some of the columns that you won't need for training or additional feature building." |
| 104 | + "Remove some of the columns that you won't need for training or additional feature building. Automate machine learning will automatically handle time-based features such as lpepPickupDatetime." |
133 | 105 | ] |
134 | 106 | }, |
135 | 107 | { |
|
138 | 110 | "metadata": {}, |
139 | 111 | "outputs": [], |
140 | 112 | "source": [ |
141 | | - "columns_to_remove = [\"lpepPickupDatetime\", \"lpepDropoffDatetime\", \"puLocationId\", \"doLocationId\", \"extra\", \"mtaTax\",\n", |
| 113 | + "columns_to_remove = [\"lpepDropoffDatetime\", \"puLocationId\", \"doLocationId\", \"extra\", \"mtaTax\",\n", |
142 | 114 | " \"improvementSurcharge\", \"tollsAmount\", \"ehailFee\", \"tripType\", \"rateCodeID\", \n", |
143 | 115 | " \"storeAndFwdFlag\", \"paymentType\", \"fareAmount\", \"tipAmount\"\n", |
144 | 116 | " ]\n", |
|
0 commit comments