@elaraai/east-py-datascience 1.0.1 → 1.0.2
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/dist/src/alns/alns.d.ts +528 -0
- package/dist/src/alns/alns.d.ts.map +1 -0
- package/dist/src/alns/alns.js +238 -0
- package/dist/src/alns/alns.js.map +1 -0
- package/dist/src/google_or/google_or.d.ts +2457 -0
- package/dist/src/google_or/google_or.d.ts.map +1 -0
- package/dist/src/google_or/google_or.js +547 -0
- package/dist/src/google_or/google_or.js.map +1 -0
- package/dist/src/gp/gp.d.ts +447 -0
- package/dist/src/gp/gp.d.ts.map +1 -0
- package/dist/src/gp/gp.js +222 -0
- package/dist/src/gp/gp.js.map +1 -0
- package/dist/src/index.d.ts +34 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +57 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lightgbm/lightgbm.d.ts +575 -0
- package/dist/src/lightgbm/lightgbm.d.ts.map +1 -0
- package/dist/src/lightgbm/lightgbm.js +241 -0
- package/dist/src/lightgbm/lightgbm.js.map +1 -0
- package/dist/src/lightning/lightning.d.ts +1594 -0
- package/dist/src/lightning/lightning.d.ts.map +1 -0
- package/dist/src/lightning/lightning.js +468 -0
- package/dist/src/lightning/lightning.js.map +1 -0
- package/dist/src/mads/mads.d.ts +410 -0
- package/dist/src/mads/mads.d.ts.map +1 -0
- package/dist/src/mads/mads.js +219 -0
- package/dist/src/mads/mads.js.map +1 -0
- package/dist/src/mapie/mapie.d.ts +3680 -0
- package/dist/src/mapie/mapie.d.ts.map +1 -0
- package/dist/src/mapie/mapie.js +616 -0
- package/dist/src/mapie/mapie.js.map +1 -0
- package/dist/src/ngboost/ngboost.d.ts +483 -0
- package/dist/src/ngboost/ngboost.d.ts.map +1 -0
- package/dist/src/ngboost/ngboost.js +231 -0
- package/dist/src/ngboost/ngboost.js.map +1 -0
- package/dist/src/optimization/optimization.d.ts +700 -0
- package/dist/src/optimization/optimization.d.ts.map +1 -0
- package/dist/src/optimization/optimization.js +411 -0
- package/dist/src/optimization/optimization.js.map +1 -0
- package/dist/src/optuna/optuna.d.ts +857 -0
- package/dist/src/optuna/optuna.d.ts.map +1 -0
- package/dist/src/optuna/optuna.js +270 -0
- package/dist/src/optuna/optuna.js.map +1 -0
- package/dist/src/pymc/pymc.d.ts +2932 -0
- package/dist/src/pymc/pymc.d.ts.map +1 -0
- package/dist/src/pymc/pymc.js +688 -0
- package/dist/src/pymc/pymc.js.map +1 -0
- package/dist/src/scipy/scipy.d.ts +2205 -0
- package/dist/src/scipy/scipy.d.ts.map +1 -0
- package/dist/src/scipy/scipy.js +884 -0
- package/dist/src/scipy/scipy.js.map +1 -0
- package/dist/src/shap/shap.d.ts +4611 -0
- package/dist/src/shap/shap.d.ts.map +1 -0
- package/dist/src/shap/shap.js +552 -0
- package/dist/src/shap/shap.js.map +1 -0
- package/dist/src/simanneal/simanneal.d.ts +628 -0
- package/dist/src/simanneal/simanneal.d.ts.map +1 -0
- package/dist/src/simanneal/simanneal.js +328 -0
- package/dist/src/simanneal/simanneal.js.map +1 -0
- package/dist/src/simulation/simulation.d.ts +224 -0
- package/dist/src/simulation/simulation.d.ts.map +1 -0
- package/dist/src/simulation/simulation.js +189 -0
- package/dist/src/simulation/simulation.js.map +1 -0
- package/dist/src/sklearn/sklearn.d.ts +6362 -0
- package/dist/src/sklearn/sklearn.d.ts.map +1 -0
- package/dist/src/sklearn/sklearn.js +1508 -0
- package/dist/src/sklearn/sklearn.js.map +1 -0
- package/dist/src/torch/torch.d.ts +1205 -0
- package/dist/src/torch/torch.d.ts.map +1 -0
- package/dist/src/torch/torch.js +440 -0
- package/dist/src/torch/torch.js.map +1 -0
- package/dist/src/types.d.ts +43 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +44 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/xgboost/xgboost.d.ts +1424 -0
- package/dist/src/xgboost/xgboost.d.ts.map +1 -0
- package/dist/src/xgboost/xgboost.js +432 -0
- package/dist/src/xgboost/xgboost.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* NGBoost platform functions for East.
|
|
7
|
+
*
|
|
8
|
+
* Provides probabilistic predictions with natural gradient boosting.
|
|
9
|
+
* Returns mean, standard deviation, and confidence intervals.
|
|
10
|
+
* Uses cloudpickle for model serialization.
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
import { East, StructType, VariantType, OptionType, IntegerType, FloatType, BlobType, NullType, } from "@elaraai/east";
|
|
15
|
+
import { VectorType, MatrixType } from "../types.js";
|
|
16
|
+
// Re-export shared types for convenience
|
|
17
|
+
export { VectorType, MatrixType } from "../types.js";
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// Enum Types
|
|
20
|
+
// ============================================================================
|
|
21
|
+
/**
|
|
22
|
+
* Distribution type for NGBoost.
|
|
23
|
+
*/
|
|
24
|
+
export const NGBoostDistributionType = VariantType({
|
|
25
|
+
/** Normal (Gaussian) distribution */
|
|
26
|
+
normal: NullType,
|
|
27
|
+
/** Log-normal distribution (for positive targets) */
|
|
28
|
+
lognormal: NullType,
|
|
29
|
+
});
|
|
30
|
+
// ============================================================================
|
|
31
|
+
// Config Types
|
|
32
|
+
// ============================================================================
|
|
33
|
+
/**
|
|
34
|
+
* Configuration for NGBoost models.
|
|
35
|
+
*/
|
|
36
|
+
export const NGBoostConfigType = StructType({
|
|
37
|
+
/** Number of boosting rounds (default 500) */
|
|
38
|
+
n_estimators: OptionType(IntegerType),
|
|
39
|
+
/** Learning rate / step size shrinkage (default 0.01) */
|
|
40
|
+
learning_rate: OptionType(FloatType),
|
|
41
|
+
/** Fraction of samples to use in each iteration (default 1.0) */
|
|
42
|
+
minibatch_frac: OptionType(FloatType),
|
|
43
|
+
/** Fraction of features to use in each iteration (default 1.0) */
|
|
44
|
+
col_sample: OptionType(FloatType),
|
|
45
|
+
/** Random seed for reproducibility */
|
|
46
|
+
random_state: OptionType(IntegerType),
|
|
47
|
+
/** Distribution type (default normal) */
|
|
48
|
+
distribution: OptionType(NGBoostDistributionType),
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Configuration for NGBoost predictions with uncertainty.
|
|
52
|
+
*/
|
|
53
|
+
export const NGBoostPredictConfigType = StructType({
|
|
54
|
+
/** Confidence level for intervals (default 0.95) */
|
|
55
|
+
confidence_level: OptionType(FloatType),
|
|
56
|
+
});
|
|
57
|
+
// ============================================================================
|
|
58
|
+
// Result Types
|
|
59
|
+
// ============================================================================
|
|
60
|
+
/**
|
|
61
|
+
* Result type for probabilistic predictions.
|
|
62
|
+
*/
|
|
63
|
+
export const NGBoostPredictResultType = StructType({
|
|
64
|
+
/** Point predictions (mean) */
|
|
65
|
+
predictions: VectorType(FloatType),
|
|
66
|
+
/** Standard deviation */
|
|
67
|
+
std: OptionType(VectorType(FloatType)),
|
|
68
|
+
/** Lower confidence interval */
|
|
69
|
+
lower: OptionType(VectorType(FloatType)),
|
|
70
|
+
/** Upper confidence interval */
|
|
71
|
+
upper: OptionType(VectorType(FloatType)),
|
|
72
|
+
});
|
|
73
|
+
// ============================================================================
|
|
74
|
+
// Model Blob Types
|
|
75
|
+
// ============================================================================
|
|
76
|
+
/**
|
|
77
|
+
* Model blob type for serialized NGBoost models.
|
|
78
|
+
*/
|
|
79
|
+
export const NGBoostModelBlobType = VariantType({
|
|
80
|
+
/** NGBoost regressor model */
|
|
81
|
+
ngboost_regressor: StructType({
|
|
82
|
+
/** Cloudpickle serialized model */
|
|
83
|
+
data: BlobType,
|
|
84
|
+
/** Distribution type used */
|
|
85
|
+
distribution: NGBoostDistributionType,
|
|
86
|
+
/** Number of input features */
|
|
87
|
+
n_features: IntegerType,
|
|
88
|
+
}),
|
|
89
|
+
});
|
|
90
|
+
// ============================================================================
|
|
91
|
+
// Platform Functions
|
|
92
|
+
// ============================================================================
|
|
93
|
+
/**
|
|
94
|
+
* Train an NGBoost regression model with probabilistic output.
|
|
95
|
+
*
|
|
96
|
+
* @param X - Feature matrix
|
|
97
|
+
* @param y - Target vector
|
|
98
|
+
* @param config - NGBoost configuration
|
|
99
|
+
* @returns Model blob containing trained regressor
|
|
100
|
+
*/
|
|
101
|
+
export const ngboost_train_regressor = East.platform("ngboost_train_regressor", [MatrixType(FloatType), VectorType(FloatType), NGBoostConfigType], NGBoostModelBlobType);
|
|
102
|
+
/**
|
|
103
|
+
* Make point predictions (mean) with a trained NGBoost regressor.
|
|
104
|
+
*
|
|
105
|
+
* @param model - Trained regressor model blob
|
|
106
|
+
* @param X - Feature matrix
|
|
107
|
+
* @returns Predicted values (mean of predictive distribution)
|
|
108
|
+
*/
|
|
109
|
+
export const ngboost_predict = East.platform("ngboost_predict", [NGBoostModelBlobType, MatrixType(FloatType)], VectorType(FloatType));
|
|
110
|
+
/**
|
|
111
|
+
* Get predictions with full uncertainty from NGBoost regressor.
|
|
112
|
+
*
|
|
113
|
+
* Returns mean, standard deviation, and confidence intervals.
|
|
114
|
+
*
|
|
115
|
+
* @param model - Trained regressor model blob
|
|
116
|
+
* @param X - Feature matrix
|
|
117
|
+
* @param config - Prediction configuration (confidence level)
|
|
118
|
+
* @returns Predictions with uncertainty estimates
|
|
119
|
+
*/
|
|
120
|
+
export const ngboost_predict_dist = East.platform("ngboost_predict_dist", [NGBoostModelBlobType, MatrixType(FloatType), NGBoostPredictConfigType], NGBoostPredictResultType);
|
|
121
|
+
// ============================================================================
|
|
122
|
+
// Grouped Export
|
|
123
|
+
// ============================================================================
|
|
124
|
+
/**
|
|
125
|
+
* Type definitions for NGBoost functions.
|
|
126
|
+
*/
|
|
127
|
+
export const NGBoostTypes = {
|
|
128
|
+
/** Distribution type for NGBoost */
|
|
129
|
+
NGBoostDistributionType,
|
|
130
|
+
/** NGBoost configuration type */
|
|
131
|
+
NGBoostConfigType,
|
|
132
|
+
/** Prediction configuration type */
|
|
133
|
+
NGBoostPredictConfigType,
|
|
134
|
+
/** Prediction result type */
|
|
135
|
+
NGBoostPredictResultType,
|
|
136
|
+
/** Model blob type for NGBoost models */
|
|
137
|
+
ModelBlobType: NGBoostModelBlobType,
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* NGBoost probabilistic gradient boosting.
|
|
141
|
+
*
|
|
142
|
+
* Provides regression with uncertainty quantification using natural gradient boosting.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* import { East, variant } from "@elaraai/east";
|
|
147
|
+
* import { NGBoost } from "@elaraai/east-py-datascience";
|
|
148
|
+
*
|
|
149
|
+
* const train = East.function([], NGBoost.Types.ModelBlobType, $ => {
|
|
150
|
+
* const X = $.let([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0], [7.0, 8.0]]);
|
|
151
|
+
* const y = $.let([1.0, 2.0, 3.0, 4.0]);
|
|
152
|
+
* const config = $.let({
|
|
153
|
+
* n_estimators: variant('some', 100n),
|
|
154
|
+
* learning_rate: variant('some', 0.01),
|
|
155
|
+
* minibatch_frac: variant('none', null),
|
|
156
|
+
* col_sample: variant('none', null),
|
|
157
|
+
* random_state: variant('some', 42n),
|
|
158
|
+
* distribution: variant('none', null),
|
|
159
|
+
* });
|
|
160
|
+
* return $.return(NGBoost.trainRegressor(X, y, config));
|
|
161
|
+
* });
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
export const NGBoost = {
|
|
165
|
+
/**
|
|
166
|
+
* Train an NGBoost regression model with probabilistic output.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* import { East, FloatType, MatrixType, VectorType, variant } from "@elaraai/east";
|
|
171
|
+
* import { NGBoost, NGBoostConfigType } from "@elaraai/east-py-datascience";
|
|
172
|
+
*
|
|
173
|
+
* const train = East.function([], NGBoost.Types.ModelBlobType, ($) => {
|
|
174
|
+
* const X = $.let([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0], [7.0, 8.0]]);
|
|
175
|
+
* const y = $.let(new Float64Array([1.0, 2.0, 3.0, 4.0]));
|
|
176
|
+
* const config = $.let({
|
|
177
|
+
* n_estimators: variant("some", 100n), learning_rate: variant("some", 0.01),
|
|
178
|
+
* minibatch_frac: variant("none", null), col_sample: variant("none", null),
|
|
179
|
+
* random_state: variant("some", 42n), distribution: variant("none", null),
|
|
180
|
+
* }, NGBoostConfigType);
|
|
181
|
+
* return $.return(NGBoost.trainRegressor(X, y, config));
|
|
182
|
+
* });
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
trainRegressor: ngboost_train_regressor,
|
|
186
|
+
/**
|
|
187
|
+
* Make point predictions with a trained NGBoost regressor.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```ts
|
|
191
|
+
* import { East, FloatType, MatrixType, VectorType } from "@elaraai/east";
|
|
192
|
+
* import { NGBoost } from "@elaraai/east-py-datascience";
|
|
193
|
+
*
|
|
194
|
+
* const predictFn = East.function(
|
|
195
|
+
* [NGBoost.Types.ModelBlobType, MatrixType(FloatType)],
|
|
196
|
+
* VectorType(FloatType),
|
|
197
|
+
* ($, model, X) => {
|
|
198
|
+
* return $.return(NGBoost.predict(model, X));
|
|
199
|
+
* }
|
|
200
|
+
* );
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
predict: ngboost_predict,
|
|
204
|
+
/**
|
|
205
|
+
* Get predictions with uncertainty estimates (confidence intervals, std).
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* import { East, FloatType, MatrixType, variant } from "@elaraai/east";
|
|
210
|
+
* import { NGBoost, NGBoostPredictConfigType } from "@elaraai/east-py-datascience";
|
|
211
|
+
*
|
|
212
|
+
* const predictFn = East.function(
|
|
213
|
+
* [NGBoost.Types.ModelBlobType, MatrixType(FloatType)],
|
|
214
|
+
* NGBoost.Types.NGBoostPredictResultType,
|
|
215
|
+
* ($, model, X) => {
|
|
216
|
+
* const config = $.let({
|
|
217
|
+
* confidence_level: variant("some", 0.95),
|
|
218
|
+
* }, NGBoostPredictConfigType);
|
|
219
|
+
* const result = $.let(NGBoost.predictDist(model, X, config));
|
|
220
|
+
* // result.predictions => point predictions
|
|
221
|
+
* // result.lower, result.upper => confidence interval
|
|
222
|
+
* return $.return(result);
|
|
223
|
+
* }
|
|
224
|
+
* );
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
predictDist: ngboost_predict_dist,
|
|
228
|
+
/** Type definitions */
|
|
229
|
+
Types: NGBoostTypes,
|
|
230
|
+
};
|
|
231
|
+
//# sourceMappingURL=ngboost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngboost.js","sourceRoot":"","sources":["../../../src/ngboost/ngboost.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAEH,OAAO,EACH,IAAI,EACJ,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,SAAS,EACT,QAAQ,EACR,QAAQ,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErD,yCAAyC;AACzC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErD,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,WAAW,CAAC;IAC/C,qCAAqC;IACrC,MAAM,EAAE,QAAQ;IAChB,qDAAqD;IACrD,SAAS,EAAE,QAAQ;CACtB,CAAC,CAAC;AAEH,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MA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