bun-scikit 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/README.md +1 -0
- package/package.json +1 -2
- package/scripts/check-benchmark-health.ts +101 -1
- package/binding.gyp +0 -21
package/docs/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bun-scikit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "A scikit-learn-inspired machine learning library for Bun/TypeScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "index.ts",
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"src",
|
|
35
35
|
"zig",
|
|
36
36
|
"scripts",
|
|
37
|
-
"binding.gyp",
|
|
38
37
|
"docs/native-abi.md",
|
|
39
38
|
"README.md",
|
|
40
39
|
"LICENSE"
|
|
@@ -31,6 +31,8 @@ interface BenchmarkSnapshot {
|
|
|
31
31
|
regression: {
|
|
32
32
|
results: [RegressionBenchmarkResult, RegressionBenchmarkResult];
|
|
33
33
|
comparison: {
|
|
34
|
+
fitSpeedupVsSklearn: number;
|
|
35
|
+
predictSpeedupVsSklearn: number;
|
|
34
36
|
mseDeltaVsSklearn: number;
|
|
35
37
|
r2DeltaVsSklearn: number;
|
|
36
38
|
};
|
|
@@ -38,16 +40,46 @@ interface BenchmarkSnapshot {
|
|
|
38
40
|
classification: {
|
|
39
41
|
results: [ClassificationBenchmarkResult, ClassificationBenchmarkResult];
|
|
40
42
|
comparison: {
|
|
43
|
+
fitSpeedupVsSklearn: number;
|
|
44
|
+
predictSpeedupVsSklearn: number;
|
|
41
45
|
accuracyDeltaVsSklearn: number;
|
|
42
46
|
f1DeltaVsSklearn: number;
|
|
43
47
|
};
|
|
44
48
|
};
|
|
45
49
|
treeClassification: {
|
|
46
|
-
models: [
|
|
50
|
+
models: [
|
|
51
|
+
TreeModelComparison & {
|
|
52
|
+
comparison: TreeModelComparison["comparison"] & {
|
|
53
|
+
fitSpeedupVsSklearn: number;
|
|
54
|
+
predictSpeedupVsSklearn: number;
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
TreeModelComparison & {
|
|
58
|
+
comparison: TreeModelComparison["comparison"] & {
|
|
59
|
+
fitSpeedupVsSklearn: number;
|
|
60
|
+
predictSpeedupVsSklearn: number;
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
];
|
|
47
64
|
};
|
|
48
65
|
};
|
|
49
66
|
}
|
|
50
67
|
|
|
68
|
+
function speedupThreshold(
|
|
69
|
+
envName: string,
|
|
70
|
+
defaultValue: number,
|
|
71
|
+
): number {
|
|
72
|
+
const raw = process.env[envName];
|
|
73
|
+
if (!raw) {
|
|
74
|
+
return defaultValue;
|
|
75
|
+
}
|
|
76
|
+
const parsed = Number(raw);
|
|
77
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
78
|
+
throw new Error(`${envName} must be a positive number when set. Got: ${raw}`);
|
|
79
|
+
}
|
|
80
|
+
return parsed;
|
|
81
|
+
}
|
|
82
|
+
|
|
51
83
|
const pathArgIndex = Bun.argv.indexOf("--input");
|
|
52
84
|
const inputPath =
|
|
53
85
|
pathArgIndex !== -1 && pathArgIndex + 1 < Bun.argv.length
|
|
@@ -59,6 +91,23 @@ const snapshot = JSON.parse(await readFile(inputPath, "utf-8")) as BenchmarkSnap
|
|
|
59
91
|
const [bunRegression, sklearnRegression] = snapshot.suites.regression.results;
|
|
60
92
|
const [bunClassification, sklearnClassification] = snapshot.suites.classification.results;
|
|
61
93
|
const [decisionTree, randomForest] = snapshot.suites.treeClassification.models;
|
|
94
|
+
const minRegressionFitSpeedup = speedupThreshold("BENCH_MIN_REGRESSION_FIT_SPEEDUP", 1.1);
|
|
95
|
+
const minRegressionPredictSpeedup = speedupThreshold("BENCH_MIN_REGRESSION_PREDICT_SPEEDUP", 1.1);
|
|
96
|
+
const minClassificationFitSpeedup = speedupThreshold("BENCH_MIN_CLASSIFICATION_FIT_SPEEDUP", 1.3);
|
|
97
|
+
const minClassificationPredictSpeedup = speedupThreshold(
|
|
98
|
+
"BENCH_MIN_CLASSIFICATION_PREDICT_SPEEDUP",
|
|
99
|
+
1.3,
|
|
100
|
+
);
|
|
101
|
+
const minDecisionTreeFitSpeedup = speedupThreshold("BENCH_MIN_DECISION_TREE_FIT_SPEEDUP", 1.2);
|
|
102
|
+
const minDecisionTreePredictSpeedup = speedupThreshold(
|
|
103
|
+
"BENCH_MIN_DECISION_TREE_PREDICT_SPEEDUP",
|
|
104
|
+
1.5,
|
|
105
|
+
);
|
|
106
|
+
const minRandomForestFitSpeedup = speedupThreshold("BENCH_MIN_RANDOM_FOREST_FIT_SPEEDUP", 2.0);
|
|
107
|
+
const minRandomForestPredictSpeedup = speedupThreshold(
|
|
108
|
+
"BENCH_MIN_RANDOM_FOREST_PREDICT_SPEEDUP",
|
|
109
|
+
2.0,
|
|
110
|
+
);
|
|
62
111
|
|
|
63
112
|
for (const result of [
|
|
64
113
|
bunRegression,
|
|
@@ -99,6 +148,18 @@ if (Math.abs(snapshot.suites.regression.comparison.mseDeltaVsSklearn) > 0.01) {
|
|
|
99
148
|
);
|
|
100
149
|
}
|
|
101
150
|
|
|
151
|
+
if (snapshot.suites.regression.comparison.fitSpeedupVsSklearn < minRegressionFitSpeedup) {
|
|
152
|
+
throw new Error(
|
|
153
|
+
`Regression fit speedup too low: ${snapshot.suites.regression.comparison.fitSpeedupVsSklearn} < ${minRegressionFitSpeedup}.`,
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (snapshot.suites.regression.comparison.predictSpeedupVsSklearn < minRegressionPredictSpeedup) {
|
|
158
|
+
throw new Error(
|
|
159
|
+
`Regression predict speedup too low: ${snapshot.suites.regression.comparison.predictSpeedupVsSklearn} < ${minRegressionPredictSpeedup}.`,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
102
163
|
if (Math.abs(snapshot.suites.regression.comparison.r2DeltaVsSklearn) > 0.01) {
|
|
103
164
|
throw new Error(
|
|
104
165
|
`Regression R2 delta too large: ${snapshot.suites.regression.comparison.r2DeltaVsSklearn}.`,
|
|
@@ -117,6 +178,21 @@ if (Math.abs(snapshot.suites.classification.comparison.f1DeltaVsSklearn) > 0.05)
|
|
|
117
178
|
);
|
|
118
179
|
}
|
|
119
180
|
|
|
181
|
+
if (snapshot.suites.classification.comparison.fitSpeedupVsSklearn < minClassificationFitSpeedup) {
|
|
182
|
+
throw new Error(
|
|
183
|
+
`Classification fit speedup too low: ${snapshot.suites.classification.comparison.fitSpeedupVsSklearn} < ${minClassificationFitSpeedup}.`,
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (
|
|
188
|
+
snapshot.suites.classification.comparison.predictSpeedupVsSklearn <
|
|
189
|
+
minClassificationPredictSpeedup
|
|
190
|
+
) {
|
|
191
|
+
throw new Error(
|
|
192
|
+
`Classification predict speedup too low: ${snapshot.suites.classification.comparison.predictSpeedupVsSklearn} < ${minClassificationPredictSpeedup}.`,
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
120
196
|
if (Math.abs(decisionTree.comparison.accuracyDeltaVsSklearn) > 0.08) {
|
|
121
197
|
throw new Error(
|
|
122
198
|
`DecisionTree accuracy delta too large: ${decisionTree.comparison.accuracyDeltaVsSklearn}.`,
|
|
@@ -127,6 +203,18 @@ if (Math.abs(decisionTree.comparison.f1DeltaVsSklearn) > 0.08) {
|
|
|
127
203
|
throw new Error(`DecisionTree F1 delta too large: ${decisionTree.comparison.f1DeltaVsSklearn}.`);
|
|
128
204
|
}
|
|
129
205
|
|
|
206
|
+
if (decisionTree.comparison.fitSpeedupVsSklearn < minDecisionTreeFitSpeedup) {
|
|
207
|
+
throw new Error(
|
|
208
|
+
`DecisionTree fit speedup too low: ${decisionTree.comparison.fitSpeedupVsSklearn} < ${minDecisionTreeFitSpeedup}.`,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (decisionTree.comparison.predictSpeedupVsSklearn < minDecisionTreePredictSpeedup) {
|
|
213
|
+
throw new Error(
|
|
214
|
+
`DecisionTree predict speedup too low: ${decisionTree.comparison.predictSpeedupVsSklearn} < ${minDecisionTreePredictSpeedup}.`,
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
130
218
|
if (Math.abs(randomForest.comparison.accuracyDeltaVsSklearn) > 0.08) {
|
|
131
219
|
throw new Error(
|
|
132
220
|
`RandomForest accuracy delta too large: ${randomForest.comparison.accuracyDeltaVsSklearn}.`,
|
|
@@ -137,4 +225,16 @@ if (Math.abs(randomForest.comparison.f1DeltaVsSklearn) > 0.08) {
|
|
|
137
225
|
throw new Error(`RandomForest F1 delta too large: ${randomForest.comparison.f1DeltaVsSklearn}.`);
|
|
138
226
|
}
|
|
139
227
|
|
|
228
|
+
if (randomForest.comparison.fitSpeedupVsSklearn < minRandomForestFitSpeedup) {
|
|
229
|
+
throw new Error(
|
|
230
|
+
`RandomForest fit speedup too low: ${randomForest.comparison.fitSpeedupVsSklearn} < ${minRandomForestFitSpeedup}.`,
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (randomForest.comparison.predictSpeedupVsSklearn < minRandomForestPredictSpeedup) {
|
|
235
|
+
throw new Error(
|
|
236
|
+
`RandomForest predict speedup too low: ${randomForest.comparison.predictSpeedupVsSklearn} < ${minRandomForestPredictSpeedup}.`,
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
140
240
|
console.log("Benchmark comparison health checks passed.");
|
package/binding.gyp
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"targets": [
|
|
3
|
-
{
|
|
4
|
-
"target_name": "bun_scikit_node_addon",
|
|
5
|
-
"sources": [ "src/native/node-addon/bun_scikit_addon.cpp" ],
|
|
6
|
-
"include_dirs": [
|
|
7
|
-
"<!@(node -p \"require('node-addon-api').include\")"
|
|
8
|
-
],
|
|
9
|
-
"dependencies": [
|
|
10
|
-
"<!(node -p \"require('node-addon-api').gyp\")"
|
|
11
|
-
],
|
|
12
|
-
"defines": [ "NAPI_DISABLE_CPP_EXCEPTIONS" ],
|
|
13
|
-
"cflags_cc!": [ "-fno-exceptions" ],
|
|
14
|
-
"msvs_settings": {
|
|
15
|
-
"VCCLCompilerTool": {
|
|
16
|
-
"ExceptionHandling": 0
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
}
|