save progress

This commit is contained in:
Anton Nesterov 2024-09-30 22:41:48 +02:00
parent 60b929db2b
commit 2ad3e91a2c
No known key found for this signature in database
GPG key ID: 59121E8AE2851FB5
8 changed files with 104 additions and 63 deletions

BIN
bun.lockb

Binary file not shown.

View file

@ -0,0 +1,21 @@
x,y
0.03857092316235833,0.06639132321684607
0.16677634653232146,1.0274832977473267
0.1831527336532205,1.2453018088581933
0.1873586470614216,1.0047814627724303
0.2431156753134085,1.2641206967402017
0.2892992815482438,0.4983300116283211
0.3428052291614103,0.5975017977451754
0.3454986400504001,0.629410260984959
0.3864771696146654,0.8227045670178283
0.4300468142111865,0.5575805722415722
0.4844984551528021,0.5650526186807526
0.4919289392847462,-0.3932219581301353
0.6149324753622187,-0.912891706931243
0.6380539847173851,-1.1282498703551047
0.6977363851237776,-1.1104554694371696
0.7024274240680553,-0.5703425644056388
0.7290856206264126,-0.6202092269771708
0.8734008431011248,-0.8732355889131802
0.8980071182251496,-0.18747150111083224
0.9509640316267164,-0.02581538043416365
1 x y
2 0.03857092316235833 0.06639132321684607
3 0.16677634653232146 1.0274832977473267
4 0.1831527336532205 1.2453018088581933
5 0.1873586470614216 1.0047814627724303
6 0.2431156753134085 1.2641206967402017
7 0.2892992815482438 0.4983300116283211
8 0.3428052291614103 0.5975017977451754
9 0.3454986400504001 0.629410260984959
10 0.3864771696146654 0.8227045670178283
11 0.4300468142111865 0.5575805722415722
12 0.4844984551528021 0.5650526186807526
13 0.4919289392847462 -0.3932219581301353
14 0.6149324753622187 -0.912891706931243
15 0.6380539847173851 -1.1282498703551047
16 0.6977363851237776 -1.1104554694371696
17 0.7024274240680553 -0.5703425644056388
18 0.7290856206264126 -0.6202092269771708
19 0.8734008431011248 -0.8732355889131802
20 0.8980071182251496 -0.18747150111083224
21 0.9509640316267164 -0.02581538043416365

File diff suppressed because one or more lines are too long

3
package.json vendored
View file

@ -7,5 +7,8 @@
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"nodejs-polars": "^0.15.0"
}
}

Binary file not shown.

View file

@ -86,6 +86,8 @@ func PlotterLinesFromJSObject(object js.Value, plt *plot.Plot, plotters *[]plot.
g.Shape = draw.PlusGlyph{}
case "ring":
g.Shape = draw.RingGlyph{}
case "circle":
g.Shape = draw.CircleGlyph{}
case "square":
g.Shape = draw.SquareGlyph{}
case "triangle":
@ -172,7 +174,7 @@ func PlotterLinesFromJSObject(object js.Value, plt *plot.Plot, plotters *[]plot.
if legend != "" {
plt.Legend.Add(legend, l, lp)
}
case "fitLinear":
case "trend":
X := make([]float64, len(XYs))
Y := make([]float64, len(XYs))
min := XYs[0].Y

22
regr/main.go Normal file
View file

@ -0,0 +1,22 @@
//go:build js && wasm
// +build js,wasm
package main
import (
"l12.xyz/x/shortcuts/regr/src"
"syscall/js"
)
func InitRegrExports(this js.Value, args []js.Value) interface{} {
exports := args[0]
exports.Set("ABCD", js.FuncOf(src.ABCD))
return nil
}
func main() {
c := make(chan struct{}, 0)
js.Global().Set("__InitRegrExports", js.FuncOf(InitRegrExports))
<-c
}

16
regr/src/Linear.go Normal file
View file

@ -0,0 +1,16 @@
//go:build js && wasm
// +build js,wasm
package src
import "syscall/js"
// ref: mat.Dense
// fit: solve least squares
// predict: predict y from x
// save: save model
// load: load model
// note: separate wasm/js glue
func ABCD(this js.Value, args []js.Value) interface{} {
return nil
}