From 868bf08a07fc1925ae70e6a8cbb07b500e995772 Mon Sep 17 00:00:00 2001 From: Anton Nesterov Date: Sun, 29 Sep 2024 16:32:23 +0200 Subject: [PATCH] ref: exlude notebooks from stats --- .gitattributes | 4 ++++ encoding.ts | 17 +++++++++-------- mod.ts | 2 +- notebooks/deno_tinygo_wasm.ipynb | 6 +++--- package.json | 2 +- 5 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..58f407d --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +notebooks/* linguist-vendored +lib/* linguist-vendored +Makefile linguist-vendored +*.json linguist-vendored \ No newline at end of file diff --git a/encoding.ts b/encoding.ts index 9592b1c..257aa7f 100644 --- a/encoding.ts +++ b/encoding.ts @@ -1,9 +1,10 @@ +// deno-lint-ignore-file no-explicit-any import pl from "npm:nodejs-polars"; export function oneHotEncoding(dataframe: pl.DataFrame): pl.DataFrame { let df = pl.DataFrame(); for (const columnName of dataframe.columns) { - const column = dataframe[columnName]; + const column = (dataframe as any)[columnName]; if (!column.isNumeric()) { df = df.hstack(column.toDummies()); } else { @@ -19,7 +20,7 @@ export function polynomialTransform( interaction_only = false, include_bias = true, ): pl.DataFrame { - let polyRecords: number[][] = []; + const polyRecords: number[][] = []; dataframe.map((X: number[]) => { polyRecords.push( polynomialFeatures(X, degree, interaction_only, include_bias), @@ -38,7 +39,7 @@ export function polynomialFeatures( let prev_chunk = [...X]; const indices = Array.from({ length: X.length }, (_, i) => i); for (let d = 1; d < degree; d++) { - const new_chunk: any[] = []; + const new_chunk: number[] = []; for (let i = 0; i < (interaction_only ? X.length - d : X.length); i++) { const v = X[i]; const next_index = new_chunk.length; @@ -71,13 +72,13 @@ export function augmentMeanForward( df: pl.DataFrame, interval = 100, ) { - let sorted = df.sort(feature); - let featIdx = sorted.findIdxByName(feature); + const sorted = df.sort(feature); + const featIdx = sorted.findIdxByName(feature); let result = sorted.head(1); for (let i = 0; i < sorted.height; i++) { - let p1 = sorted.row(i).at(featIdx); - let k = (i + 1) % sorted.height; - let p2 = sorted.row(k).at(featIdx); + const p1 = sorted.row(i).at(featIdx); + const k = (i + 1) % sorted.height; + const p2 = sorted.row(k).at(featIdx); if (p2 - p1 > interval) { for (let j = 0; j < Math.round((p2 - p1) / interval) - 1; j++) { result = pl.concat([ diff --git a/mod.ts b/mod.ts index f67b2c6..2a5e4b8 100644 --- a/mod.ts +++ b/mod.ts @@ -1 +1 @@ -console.log("Hello via Bun!"); \ No newline at end of file +console.log("Hello via Bun!"); diff --git a/notebooks/deno_tinygo_wasm.ipynb b/notebooks/deno_tinygo_wasm.ipynb index 1db6ba5..73fab97 100644 --- a/notebooks/deno_tinygo_wasm.ipynb +++ b/notebooks/deno_tinygo_wasm.ipynb @@ -24,8 +24,8 @@ "const ys = [];\n", "\n", "for (let i = 0; i < 100; i++) {\n", - " xs.push(i);\n", - " ys.push((1 + 3 * i) + Math.random());\n", + " xs.push(i);\n", + " ys.push((1 + 3 * i) + Math.random());\n", "}\n", "\n", "const linreg = stats.LinearRegression(xs, ys, [], false);\n", @@ -34,7 +34,7 @@ "console.log(\"\\nLinear Regression Line:\");\n", "console.log(\"\\tEstimated offset is: \", linreg.alpha.toFixed(6));\n", "console.log(\"\\tEstimated slope is: \", linreg.beta.toFixed(6));\n", - "console.log(\"\\tR^2 is: \", r.toFixed(6));\n" + "console.log(\"\\tR^2 is: \", r.toFixed(6));" ] } ], diff --git a/package.json b/package.json index b8d727c..9d909d2 100644 --- a/package.json +++ b/package.json @@ -8,4 +8,4 @@ "peerDependencies": { "typescript": "^5.0.0" } -} \ No newline at end of file +}