Skip to content

Commit

Permalink
Update API for haversine and predictions output in notebook.ipynb (#329)
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Tomlinson <[email protected]>
  • Loading branch information
taureandyernv and jacobtomlinson authored Feb 7, 2024
1 parent d428ae4 commit 476e3fa
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions source/examples/rapids-ec2-mnmg/notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "98cf9dae",
"metadata": {},
Expand All @@ -46,7 +45,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "3af8c63a",
"metadata": {},
Expand All @@ -70,7 +68,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "f933be1c",
"metadata": {},
Expand Down Expand Up @@ -145,7 +142,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "909a9714",
"metadata": {
"tags": []
Expand Down Expand Up @@ -312,13 +309,13 @@
"def haversine_dist(df):\n",
" import cuspatial\n",
"\n",
" h_distance = cuspatial.haversine_distance(\n",
" df[\"pickup_longitude\"],\n",
" df[\"pickup_latitude\"],\n",
" df[\"dropoff_longitude\"],\n",
" df[\"dropoff_latitude\"],\n",
" pickup = cuspatial.GeoSeries.from_points_xy(\n",
" df[[\"pickup_longitude\", \"pickup_latitude\"]].interleave_columns()\n",
" )\n",
" dropoff = cuspatial.GeoSeries.from_points_xy(\n",
" df[[\"dropoff_longitude\", \"dropoff_latitude\"]].interleave_columns()\n",
" )\n",
" df[\"h_distance\"] = h_distance\n",
" df[\"h_distance\"] = cuspatial.haversine_distance(pickup, dropoff)\n",
" df[\"h_distance\"] = df[\"h_distance\"].astype(\"float32\")\n",
" return df\n",
"\n",
Expand Down Expand Up @@ -422,18 +419,22 @@
"cell_type": "code",
"execution_count": null,
"id": "b1bff0d6",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# compute RMSE\n",
"score = mean_squared_error(y_pred.compute().to_array(), y_test.compute().to_array())\n",
"score = mean_squared_error(y_pred.compute().to_numpy(), y_test.compute().to_numpy())\n",
"print(\"Workflow Complete - RMSE: \", np.sqrt(score))"
]
},
{
"cell_type": "markdown",
"id": "44f0d5d2",
"metadata": {},
"metadata": {
"tags": []
},
"source": [
"### Resource Cleanup"
]
Expand Down Expand Up @@ -463,7 +464,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -477,7 +478,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
"version": "3.10.13"
},
"vscode": {
"interpreter": {
Expand Down

0 comments on commit 476e3fa

Please sign in to comment.