Skip to content

Commit 3d8ba78

Browse files
committed
fix ollama; update rate mapping doc
1 parent c5ba014 commit 3d8ba78

6 files changed

Lines changed: 186 additions & 135 deletions

File tree

docs/spatial-analysis-tutorial/rate-mapping.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,37 @@ While easy to calculate, the estimate for the variance can yield negative values
196196

197197
### EB rate map
198198

199-
You can use the following prompt to create an EB smoothed rate map:
199+
You can use the following prompt to create an EB smoothed rate map by using the dataset with raw rates, which we will compare to the EB rates in the next step:
200200

201201
```
202-
Can you calculate the empirical bayes smoothed rates using event variable LFW68 and base variable POPFW68, and create a box map using the empirical bayes smoothed rates?
202+
Can you calculate the empirical bayes smoothed rates using event variable LFW68 and base variable POPFW68 from dataset with raw rates, and create a box map using the empirical bayes smoothed rates?
203203
```
204204

205-
<img>
205+
<img width="1324" alt="Screenshot 2025-06-23 at 7 24 53 PM" src="https://github.com/user-attachments/assets/471c6e4a-aac5-4df0-b9d5-50cf481de7b9" />
206206

207207
In comparison to the box map for the crude rates and the excess rate map, none of the original outliers remain identified as such in the smoothed map. Instead, a new outlier is shown in the very southwestern corner of the state (Hamilton county).
208208

209209
Since many of the original outlier counties have small populations at risk (check in the data table), their EB smoothed rates are quite different (lower) from the original. In contrast, Hamilton county is one of the most populous counties (it contains the city of Cincinnati), so that its raw rate is barely adjusted. Because of that, it percolates to the top of the distribution and becomes an outlier.
210210

211211
To illustrate this phenomenon, we can systematically select observations in the box plot for the raw rates and compare their position in the box plot for the smoothed rates. This will reveal which observations are affected most.
212212

213+
We create the box plots in the usual way using the raw rates and the empirical bayes smoothed rates by prompting:
214+
215+
```
216+
Can you create a box plot for the raw rates and the empirical bayes smoothed rates?
217+
```
218+
219+
<img width="1222" alt="Screenshot 2025-06-23 at 8 11 51 PM" src="https://github.com/user-attachments/assets/7a8f0a1c-9d5e-418d-a089-88af81ad7351" />
220+
221+
Now, the AI assistant will create two box plots for the raw rates and the empirical bayes smoothed rates. We select the three outliers in the raw rates box plot. The corresponding observations are within the upper quartile for the EB smoothed rates, but well within the fence, and thus no longer outliers after smoothing. We can of course also locate these observations on the map, or any other open views.
222+
223+
<img width="1123" alt="Screenshot 2025-06-23 at 8 15 36 PM" src="https://github.com/user-attachments/assets/ff24346c-c804-42e3-9430-b2d2b40097a5" />
224+
225+
Next, we can carry out the reverse and select the outlier in the box plot for the EB smoothed rate. Its position is around the 75 percentile in the box plot for the crude rate. Also note how the range of the rates has shrunk. Many of the higher crude rates are well below 0.00012 for the EB rate, whereas the value for the EB outlier has barely changed.
226+
227+
<img width="1129" alt="Screenshot 2025-06-23 at 8 15 19 PM" src="https://github.com/user-attachments/assets/c38531b0-bc50-4a46-aed8-0681f2535606" />
228+
229+
230+
Here is a screen captured video of the above steps:
231+
232+
![rates_box_plots-1](https://github.com/user-attachments/assets/62a416e8-d54b-4a74-a81a-777cf0cea103)

examples/demo-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
"@loaders.gl/csv": "^4.3.2",
3232
"@loaders.gl/json": "^4.3.2",
3333
"@loaders.gl/parquet": "^4.3.2",
34-
"@openassistant/core": "^0.5.11",
35-
"@openassistant/ui": "^0.5.11",
34+
"@openassistant/core": "^0.5.13",
35+
"@openassistant/ui": "^0.5.13",
3636
"@types/classnames": "^2.3.1",
3737
"@types/keymirror": "^0.1.1",
3838
"apache-arrow": ">=15.0.0",

examples/demo-app/yarn.lock

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6290,9 +6290,9 @@ __metadata:
62906290
languageName: node
62916291
linkType: hard
62926292

6293-
"@openassistant/core@npm:0.5.11, @openassistant/core@npm:^0.5.11":
6294-
version: 0.5.11
6295-
resolution: "@openassistant/core@npm:0.5.11"
6293+
"@openassistant/core@npm:0.5.13, @openassistant/core@npm:^0.5.13":
6294+
version: 0.5.13
6295+
resolution: "@openassistant/core@npm:0.5.13"
62966296
dependencies:
62976297
"@ai-sdk/openai": "npm:^1.3.21"
62986298
"@ai-sdk/react": "npm:^1.2.11"
@@ -6308,7 +6308,7 @@ __metadata:
63086308
"@ai-sdk/deepseek": ^0.1.8
63096309
"@ai-sdk/google": ^1.1.8
63106310
"@ai-sdk/xai": ^1.1.8
6311-
ollama-ai-provider: ^1.2.0
6311+
ollama-ai-provider-v2: ^0.0.5
63126312
react: ">=18.2"
63136313
peerDependenciesMeta:
63146314
"@ai-sdk/anthropic":
@@ -6319,9 +6319,9 @@ __metadata:
63196319
optional: true
63206320
"@ai-sdk/xai":
63216321
optional: true
6322-
ollama-ai-provider:
6322+
ollama-ai-provider-v2:
63236323
optional: true
6324-
checksum: 10c0/851c729d11c253e20f0635af32500627912295a41642237256cce75386363f12d193852af9a8cd0757cf30254b0ad830fa928fe21885fe055a5f533a384428ae
6324+
checksum: 10c0/46cf0831dd170b125b5ac1754b7ebbcff84f11158574dc51602f1b6ddf02953411d9a500440775f07f2e7fca8707d3295eb5d69676ac561d6d893c35d5b665f0
63256325
languageName: node
63266326
linkType: hard
63276327

@@ -6402,16 +6402,16 @@ __metadata:
64026402
languageName: node
64036403
linkType: hard
64046404

6405-
"@openassistant/ui@npm:^0.5.11":
6406-
version: 0.5.11
6407-
resolution: "@openassistant/ui@npm:0.5.11"
6405+
"@openassistant/ui@npm:^0.5.13":
6406+
version: 0.5.13
6407+
resolution: "@openassistant/ui@npm:0.5.13"
64086408
dependencies:
64096409
"@ai-sdk/ui-utils": "npm:^1.2.11"
64106410
"@heroui/react": "npm:^2.7.8"
64116411
"@heroui/use-clipboard": "npm:^2.1.8"
64126412
"@iconify/react": "npm:^5.1.0"
6413-
"@openassistant/core": "npm:0.5.11"
6414-
"@openassistant/utils": "npm:0.5.11"
6413+
"@openassistant/core": "npm:0.5.13"
6414+
"@openassistant/utils": "npm:0.5.13"
64156415
ai: "npm:^4.3.16"
64166416
framer-motion: "npm:^11.15.0"
64176417
html2canvas: "npm:^1.4.1"
@@ -6423,16 +6423,16 @@ __metadata:
64236423
peerDependencies:
64246424
react: ">=18.2"
64256425
react-dom: ">=18.2"
6426-
checksum: 10c0/c1eb97bba1ce8c30aa9643c7511be87d82fb9aedb1a9c95c1fdada41af347b7b93c7458d76b719f90588bc98046f0b48ac22cd0850bd0f1de296da33ad337ed9
6426+
checksum: 10c0/06aea41b8e1e026728f9b51518c67fea7bd5fcacbe800b8df69bd7449ef66fd929dc234cba884f9f9249acd509a213375caad1a0c94a132fa0f6473f6c42e04d
64276427
languageName: node
64286428
linkType: hard
64296429

6430-
"@openassistant/utils@npm:0.5.11":
6431-
version: 0.5.11
6432-
resolution: "@openassistant/utils@npm:0.5.11"
6430+
"@openassistant/utils@npm:0.5.13":
6431+
version: 0.5.13
6432+
resolution: "@openassistant/utils@npm:0.5.13"
64336433
dependencies:
64346434
zod: "npm:^3.24.4"
6435-
checksum: 10c0/2f8590cde745694d067beb5df4c2b66fff6c928fc2c05a1720f532de2da5791ca0878563cc6d200752f0b3e316c9cc5584c7df441b25875b95f7596f6ded6348
6435+
checksum: 10c0/3f28b04cc9d75ada1721cb4292ce4fb97acd500710db4c54b84ab74367182b31674489fa6f22c22d6d0e97649d28a73076b9c163485c80e1c29f711fea18319c
64366436
languageName: node
64376437
linkType: hard
64386438

@@ -18562,8 +18562,8 @@ __metadata:
1856218562
"@loaders.gl/csv": "npm:^4.3.2"
1856318563
"@loaders.gl/json": "npm:^4.3.2"
1856418564
"@loaders.gl/parquet": "npm:^4.3.2"
18565-
"@openassistant/core": "npm:^0.5.11"
18566-
"@openassistant/ui": "npm:^0.5.11"
18565+
"@openassistant/core": "npm:^0.5.13"
18566+
"@openassistant/ui": "npm:^0.5.13"
1856718567
"@types/classnames": "npm:^2.3.1"
1856818568
"@types/keymirror": "npm:^0.1.1"
1856918569
apache-arrow: "npm:>=15.0.0"

src/ai-assistant/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@
4040
"@kepler.gl/table": "3.1.8",
4141
"@kepler.gl/types": "3.1.8",
4242
"@kepler.gl/utils": "3.1.8",
43-
"@openassistant/core": "^0.5.11",
44-
"@openassistant/duckdb": "^0.5.11",
45-
"@openassistant/echarts": "^0.5.11",
46-
"@openassistant/geoda": "^0.5.11",
47-
"@openassistant/osm": "^0.5.11",
48-
"@openassistant/plots": "^0.5.11",
49-
"@openassistant/tables": "^0.5.11",
50-
"@openassistant/ui": "^0.5.11",
51-
"@openassistant/utils": "^0.5.11",
43+
"@openassistant/core": "^0.5.13",
44+
"@openassistant/duckdb": "^0.5.13",
45+
"@openassistant/echarts": "^0.5.13",
46+
"@openassistant/geoda": "^0.5.13",
47+
"@openassistant/osm": "^0.5.13",
48+
"@openassistant/plots": "^0.5.13",
49+
"@openassistant/tables": "^0.5.13",
50+
"@openassistant/ui": "^0.5.13",
51+
"@openassistant/utils": "^0.5.13",
5252
"color-interpolate": "^1.0.5",
5353
"global": "^4.3.0",
54-
"ollama-ai-provider": "^1.2.0",
54+
"ollama-ai-provider-v2": "^0.0.5",
5555
"react-intl": "^6.3.0",
5656
"usehooks-ts": "^3.1.0"
5757
},

src/ai-assistant/src/tools/geo-tools.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ import {
1818
SpatialJoinTool,
1919
spatialFilter,
2020
buffer,
21+
BufferTool,
2122
centroid,
23+
CentroidTool,
2224
dissolve,
25+
DissolveTool,
2326
length,
2427
area,
2528
perimeter,
26-
BufferTool,
27-
CentroidTool,
28-
DissolveTool,
2929
grid,
3030
GridTool,
3131
standardizeVariable,
@@ -35,7 +35,9 @@ import {
3535
minimumSpanningTree,
3636
MinimumSpanningTreeTool,
3737
cartogram,
38-
CartogramTool
38+
CartogramTool,
39+
rate,
40+
RateTool
3941
} from '@openassistant/geoda';
4042
import {
4143
getUsStateGeojson,
@@ -249,6 +251,12 @@ export function getGeoTools(
249251
component: CustomDataTableComponent
250252
};
251253

254+
const rateTool: RateTool = {
255+
...rate,
256+
context: {getValues},
257+
component: CustomDataTableComponent
258+
};
259+
252260
return {
253261
classifyTool,
254262
weightsTool,
@@ -275,12 +283,13 @@ export function getGeoTools(
275283
standardizeVariable: standardizeVariableTool,
276284
thiessenPolygons: thiessenPolygonsTool,
277285
minimumSpanningTree: minimumSpanningTreeTool,
278-
cartogram: cartogramTool
286+
cartogram: cartogramTool,
287+
rate: rateTool
279288
};
280289
}
281290

282291
/**
283-
* Customize the DataTableComponent for StandardizeVariableTool
292+
* Customize the DataTableComponent for StandardizeVariableTool and RateTool
284293
*/
285294
function CustomDataTableComponent(props: DataTableComponentProps) {
286295
const dispatch = useDispatch();

0 commit comments

Comments
 (0)