|
2 | 2 | "cells": [
|
3 | 3 | {
|
4 | 4 | "cell_type": "code",
|
5 |
| - "execution_count": 1, |
| 5 | + "execution_count": 13, |
6 | 6 | "metadata": {
|
7 | 7 | "jupyter": {
|
8 | 8 | "is_executing": true
|
9 | 9 | }
|
10 | 10 | },
|
11 | 11 | "outputs": [],
|
12 | 12 | "source": [
|
13 |
| - "use LLM::Configurations;" |
| 13 | + "use LLM::Configurations;\n", |
| 14 | + "use DSL::Examples;\n", |
| 15 | + "use DSL::English::QuantileRegressionWorkflows;" |
14 | 16 | ]
|
15 | 17 | },
|
16 | 18 | {
|
17 | 19 | "cell_type": "code",
|
18 |
| - "execution_count": 2, |
19 |
| - "metadata": {}, |
20 |
| - "outputs": [ |
21 |
| - { |
22 |
| - "data": { |
23 |
| - "text/plain": [ |
24 |
| - "-> **@args, *%args { #`(Block|5495820722832) ... }" |
25 |
| - ] |
26 |
| - }, |
27 |
| - "execution_count": 2, |
28 |
| - "metadata": {}, |
29 |
| - "output_type": "execute_result" |
30 |
| - } |
31 |
| - ], |
32 |
| - "source": [ |
33 |
| - "my &fLLMForQRMon = llm-example-function([\n", |
34 |
| - " 'use tsTemp' => 'Regressionizer(temp_data)',\n", |
35 |
| - " 'with the data tsTemp' => 'Regressionizer(temp_data)',\n", |
36 |
| - " 'do regression with 12 knots' => 'quantile_regression(knots=12)',\n", |
37 |
| - " 'quantile regression with 30 knots and interpolation order 3' => 'quantile_regression(knots=12,order=3)',\n", |
38 |
| - " 'compute the regression quantiles for probabilities 0.1, 0.5, and 0.9' => 'quantile_regression(knots=12, probs=[0.1, 0.5, 0.9])',\n", |
39 |
| - " 'compute linear regression' => 'least_squares_fit(funcs=6)',\n", |
40 |
| - " 'compute linear regression with 14 basis functions' => 'least_squares_fit(funcs=14)',\n", |
41 |
| - " 'do a least squares fit with the basis functions MyFuncs' => 'least_squares_fit(funcs=MyFuncs)',\n", |
42 |
| - " 'show date list plot' => 'date_list_plot()',\n", |
43 |
| - " 'plot the data and fits' => 'plot()',\n", |
44 |
| - " 'plot with width 800 and aspect ratio 1/3' => 'plot(width=800, height=800*1/3)',\n", |
45 |
| - " 'plot with image size 1000 and plot theme plotly_dark' => 'plot(width=1000, template=\\\"plotly_dark\\\")',\n", |
46 |
| - " 'show error plots' => 'error_plots()',\n", |
47 |
| - " 'show date list error plots' => 'error_plots(date_list_plot=True)',\n", |
48 |
| - " 'show relative error plots' => 'error_plots(relative_errors=True)',\n", |
49 |
| - " 'echo data summary' => 'echo_data_summary()',\n", |
50 |
| - " 'rescale the data' => 'rescale(regressor=False, value=True)',\n", |
51 |
| - " 'rescale the data in both dimensions' => 'rescale(regressor=True, value=True)',\n", |
52 |
| - " 'find outliers' => 'outliers()',\n", |
53 |
| - " 'plot outliers' => 'outliers_plot()',\n", |
54 |
| - " 'take the value' => 'take_value()',\n", |
55 |
| - " 'show the value' => 'take_value()'\n", |
56 |
| - "],\n", |
57 |
| - "e => $conf4o\n", |
58 |
| - ");" |
59 |
| - ] |
60 |
| - }, |
61 |
| - { |
62 |
| - "cell_type": "code", |
63 |
| - "execution_count": 3, |
| 20 | + "execution_count": 9, |
64 | 21 | "metadata": {},
|
65 | 22 | "outputs": [
|
66 | 23 | {
|
|
69 | 26 | "&LLMQRMon"
|
70 | 27 | ]
|
71 | 28 | },
|
72 |
| - "execution_count": 3, |
| 29 | + "execution_count": 9, |
73 | 30 | "metadata": {},
|
74 | 31 | "output_type": "execute_result"
|
75 | 32 | }
|
76 | 33 | ],
|
77 | 34 | "source": [
|
| 35 | + "use LLM::Functions;\n", |
| 36 | + "my &llm-pipeline-segment = llm-example-function(dsl-examples()<Python><QRMon>, e => $conf4o);\n", |
| 37 | + "\n", |
78 | 38 | "sub LLMQRMon(Str $s) {\n",
|
79 |
| - " my $res = &fLLMForQRMon($s);\n", |
| 39 | + " my $res = &llm-pipeline-segment($s);\n", |
80 | 40 | " $res .= trim;\n",
|
81 | 41 | " return $res;\n",
|
82 | 42 | "}"
|
83 | 43 | ]
|
84 | 44 | },
|
85 | 45 | {
|
86 | 46 | "cell_type": "code",
|
87 |
| - "execution_count": 4, |
| 47 | + "execution_count": null, |
88 | 48 | "metadata": {},
|
89 | 49 | "outputs": [
|
90 | 50 | {
|
91 | 51 | "data": {
|
92 | 52 | "text/plain": [
|
93 |
| - "[Regressionizer(temp_data) echo_data_summary() rescale(regressor=True, value=False) quantile_regression(knots=20, probs=[0.025, 0.5, 0.976]) least_squares_fit(funcs=34) date_list_plot(width=900, height=900*1/3) outliers_plot(date_list_plot=True, width=900, height=900*1/3)]" |
| 53 | + "[Regressionizer(temp_data) echo_data_summary() rescale(regressor=True, value=False) quantile_regression(knots=20, probs=[0.025, 0.5, 0.976]) least_squares_fit(funcs=34) date_list_plot(width=900, height=900*1/3) ```python\n", |
| 54 | + "date_list_plot(outliers=True, width=900, height=900*1/3)\n", |
| 55 | + "```]" |
94 | 56 | ]
|
95 | 57 | },
|
96 |
| - "execution_count": 4, |
| 58 | + "execution_count": 10, |
97 | 59 | "metadata": {},
|
98 | 60 | "output_type": "execute_result"
|
99 | 61 | }
|
|
111 | 73 | },
|
112 | 74 | {
|
113 | 75 | "cell_type": "code",
|
114 |
| - "execution_count": 5, |
| 76 | + "execution_count": 11, |
115 | 77 | "metadata": {},
|
116 | 78 | "outputs": [
|
117 | 79 | {
|
|
123 | 85 | ".quantile_regression(knots=20, probs=[0.025, 0.5, 0.976])\n",
|
124 | 86 | ".least_squares_fit(funcs=34)\n",
|
125 | 87 | ".date_list_plot(width=900, height=900*1/3)\n",
|
126 |
| - ".outliers_plot(date_list_plot=True, width=900, height=900*1/3)" |
| 88 | + ".```python\n", |
| 89 | + "date_list_plot(outliers=True, width=900, height=900*1/3)\n", |
| 90 | + "```" |
127 | 91 | ]
|
128 | 92 | },
|
129 |
| - "execution_count": 5, |
| 93 | + "execution_count": 11, |
130 | 94 | "metadata": {},
|
131 | 95 | "output_type": "execute_result"
|
132 | 96 | }
|
|
135 | 99 | "@qrPythonCode.join(\"\\n.\")"
|
136 | 100 | ]
|
137 | 101 | },
|
| 102 | + { |
| 103 | + "cell_type": "markdown", |
| 104 | + "metadata": {}, |
| 105 | + "source": [ |
| 106 | + "Compare with the \"Small Language Model\" (SML) results:" |
| 107 | + ] |
| 108 | + }, |
138 | 109 | {
|
139 | 110 | "cell_type": "code",
|
140 |
| - "execution_count": null, |
| 111 | + "execution_count": 36, |
141 | 112 | "metadata": {},
|
142 |
| - "outputs": [], |
143 |
| - "source": [] |
| 113 | + "outputs": [ |
| 114 | + { |
| 115 | + "name": "stderr", |
| 116 | + "output_type": "stream", |
| 117 | + "text": [ |
| 118 | + "Possible misspelling of 'summary' as 'summari'.\n" |
| 119 | + ] |
| 120 | + }, |
| 121 | + { |
| 122 | + "data": { |
| 123 | + "text/plain": [ |
| 124 | + "obj = Regressionizer(temp_data).echo_data_summary().rescale( regressor = True).quantile_regression( knots = 20, probs = [0.025, 0.5, 0.976] ).plot( date_plot = True).plot( datePlotQ = false)" |
| 125 | + ] |
| 126 | + }, |
| 127 | + "execution_count": 36, |
| 128 | + "metadata": {}, |
| 129 | + "output_type": "execute_result" |
| 130 | + } |
| 131 | + ], |
| 132 | + "source": [ |
| 133 | + "my $spec = q:to/END/;\n", |
| 134 | + "use dataset temp_data\n", |
| 135 | + "echo data summari;\n", |
| 136 | + "rescale the x axis;\n", |
| 137 | + "do quantile regression with 20 knots, with probabilities 0.025, 0.5, and 0.976;\n", |
| 138 | + "show date list plot;\n", |
| 139 | + "show outliers plot;\n", |
| 140 | + "END\n", |
| 141 | + "\n", |
| 142 | + "ToQuantileRegressionWorkflowCode($spec, target => 'Python::Regressionizer')" |
| 143 | + ] |
144 | 144 | }
|
145 | 145 | ],
|
146 | 146 | "metadata": {
|
|
0 commit comments