@elaraai/east-py-datascience 0.0.2-beta.8 → 0.0.2-beta.80

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.
Files changed (123) hide show
  1. package/README.md +58 -1
  2. package/dist/src/alns/alns.d.ts +528 -0
  3. package/dist/src/alns/alns.d.ts.map +1 -0
  4. package/dist/src/alns/alns.js +238 -0
  5. package/dist/src/alns/alns.js.map +1 -0
  6. package/dist/src/google_or/google_or.d.ts +2422 -0
  7. package/dist/src/google_or/google_or.d.ts.map +1 -0
  8. package/dist/src/google_or/google_or.js +542 -0
  9. package/dist/src/google_or/google_or.js.map +1 -0
  10. package/dist/{gp → src/gp}/gp.d.ts +185 -136
  11. package/dist/src/gp/gp.d.ts.map +1 -0
  12. package/dist/{gp → src/gp}/gp.js +64 -12
  13. package/dist/src/gp/gp.js.map +1 -0
  14. package/dist/src/index.d.ts +34 -0
  15. package/dist/src/index.d.ts.map +1 -0
  16. package/dist/src/index.js +57 -0
  17. package/dist/src/index.js.map +1 -0
  18. package/dist/src/lightgbm/lightgbm.d.ts +575 -0
  19. package/dist/src/lightgbm/lightgbm.d.ts.map +1 -0
  20. package/dist/{lightgbm → src/lightgbm}/lightgbm.js +104 -18
  21. package/dist/src/lightgbm/lightgbm.js.map +1 -0
  22. package/dist/src/lightning/lightning.d.ts +1594 -0
  23. package/dist/src/lightning/lightning.d.ts.map +1 -0
  24. package/dist/src/lightning/lightning.js +468 -0
  25. package/dist/src/lightning/lightning.js.map +1 -0
  26. package/dist/{mads → src/mads}/mads.d.ts +109 -112
  27. package/dist/src/mads/mads.d.ts.map +1 -0
  28. package/dist/{mads → src/mads}/mads.js +6 -8
  29. package/dist/src/mads/mads.js.map +1 -0
  30. package/dist/src/mapie/mapie.d.ts +3680 -0
  31. package/dist/src/mapie/mapie.d.ts.map +1 -0
  32. package/dist/src/mapie/mapie.js +616 -0
  33. package/dist/src/mapie/mapie.js.map +1 -0
  34. package/dist/{ngboost → src/ngboost}/ngboost.d.ts +192 -142
  35. package/dist/src/ngboost/ngboost.d.ts.map +1 -0
  36. package/dist/{ngboost → src/ngboost}/ngboost.js +67 -14
  37. package/dist/src/ngboost/ngboost.js.map +1 -0
  38. package/dist/src/optimization/optimization.d.ts +420 -0
  39. package/dist/src/optimization/optimization.d.ts.map +1 -0
  40. package/dist/src/optimization/optimization.js +257 -0
  41. package/dist/src/optimization/optimization.js.map +1 -0
  42. package/dist/{optuna → src/optuna}/optuna.d.ts +374 -314
  43. package/dist/src/optuna/optuna.d.ts.map +1 -0
  44. package/dist/{optuna → src/optuna}/optuna.js +2 -0
  45. package/dist/src/optuna/optuna.js.map +1 -0
  46. package/dist/src/pymc/pymc.d.ts +2932 -0
  47. package/dist/src/pymc/pymc.d.ts.map +1 -0
  48. package/dist/src/pymc/pymc.js +688 -0
  49. package/dist/src/pymc/pymc.js.map +1 -0
  50. package/dist/src/scipy/scipy.d.ts +2205 -0
  51. package/dist/src/scipy/scipy.d.ts.map +1 -0
  52. package/dist/src/scipy/scipy.js +884 -0
  53. package/dist/src/scipy/scipy.js.map +1 -0
  54. package/dist/src/shap/shap.d.ts +2988 -0
  55. package/dist/src/shap/shap.d.ts.map +1 -0
  56. package/dist/src/shap/shap.js +500 -0
  57. package/dist/src/shap/shap.js.map +1 -0
  58. package/dist/{simanneal → src/simanneal}/simanneal.d.ts +257 -160
  59. package/dist/src/simanneal/simanneal.d.ts.map +1 -0
  60. package/dist/{simanneal → src/simanneal}/simanneal.js +105 -8
  61. package/dist/src/simanneal/simanneal.js.map +1 -0
  62. package/dist/src/simulation/simulation.d.ts +431 -0
  63. package/dist/src/simulation/simulation.d.ts.map +1 -0
  64. package/dist/src/simulation/simulation.js +306 -0
  65. package/dist/src/simulation/simulation.js.map +1 -0
  66. package/dist/src/sklearn/sklearn.d.ts +6362 -0
  67. package/dist/src/sklearn/sklearn.d.ts.map +1 -0
  68. package/dist/src/sklearn/sklearn.js +1508 -0
  69. package/dist/src/sklearn/sklearn.js.map +1 -0
  70. package/dist/src/torch/torch.d.ts +1205 -0
  71. package/dist/src/torch/torch.d.ts.map +1 -0
  72. package/dist/{torch → src/torch}/torch.js +109 -18
  73. package/dist/src/torch/torch.js.map +1 -0
  74. package/dist/src/types.d.ts +43 -0
  75. package/dist/src/types.d.ts.map +1 -0
  76. package/dist/src/types.js +44 -0
  77. package/dist/src/types.js.map +1 -0
  78. package/dist/src/xgboost/xgboost.d.ts +1424 -0
  79. package/dist/src/xgboost/xgboost.d.ts.map +1 -0
  80. package/dist/src/xgboost/xgboost.js +432 -0
  81. package/dist/src/xgboost/xgboost.js.map +1 -0
  82. package/package.json +12 -12
  83. package/dist/gp/gp.d.ts.map +0 -1
  84. package/dist/gp/gp.js.map +0 -1
  85. package/dist/index.d.ts +0 -27
  86. package/dist/index.d.ts.map +0 -1
  87. package/dist/index.js +0 -41
  88. package/dist/index.js.map +0 -1
  89. package/dist/lightgbm/lightgbm.d.ts +0 -494
  90. package/dist/lightgbm/lightgbm.d.ts.map +0 -1
  91. package/dist/lightgbm/lightgbm.js.map +0 -1
  92. package/dist/mads/mads.d.ts.map +0 -1
  93. package/dist/mads/mads.js.map +0 -1
  94. package/dist/ngboost/ngboost.d.ts.map +0 -1
  95. package/dist/ngboost/ngboost.js.map +0 -1
  96. package/dist/optuna/optuna.d.ts.map +0 -1
  97. package/dist/optuna/optuna.js.map +0 -1
  98. package/dist/scipy/scipy.d.ts +0 -1260
  99. package/dist/scipy/scipy.d.ts.map +0 -1
  100. package/dist/scipy/scipy.js +0 -413
  101. package/dist/scipy/scipy.js.map +0 -1
  102. package/dist/shap/shap.d.ts +0 -657
  103. package/dist/shap/shap.d.ts.map +0 -1
  104. package/dist/shap/shap.js +0 -241
  105. package/dist/shap/shap.js.map +0 -1
  106. package/dist/simanneal/simanneal.d.ts.map +0 -1
  107. package/dist/simanneal/simanneal.js.map +0 -1
  108. package/dist/sklearn/sklearn.d.ts +0 -2691
  109. package/dist/sklearn/sklearn.d.ts.map +0 -1
  110. package/dist/sklearn/sklearn.js +0 -524
  111. package/dist/sklearn/sklearn.js.map +0 -1
  112. package/dist/torch/torch.d.ts +0 -1081
  113. package/dist/torch/torch.d.ts.map +0 -1
  114. package/dist/torch/torch.js.map +0 -1
  115. package/dist/tsconfig.tsbuildinfo +0 -1
  116. package/dist/types.d.ts +0 -80
  117. package/dist/types.d.ts.map +0 -1
  118. package/dist/types.js +0 -81
  119. package/dist/types.js.map +0 -1
  120. package/dist/xgboost/xgboost.d.ts +0 -504
  121. package/dist/xgboost/xgboost.d.ts.map +0 -1
  122. package/dist/xgboost/xgboost.js +0 -177
  123. package/dist/xgboost/xgboost.js.map +0 -1
@@ -0,0 +1,257 @@
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
+ * Iterative coordinate descent optimization for discrete combinatorial problems.
7
+ *
8
+ * Provides element-wise optimization over vectors of discrete integer values.
9
+ * Each element is independently optimized by trying all candidate values
10
+ * while holding other elements fixed. Multi-start sampling improves
11
+ * exploration of the search space.
12
+ *
13
+ * Ported from the Julia IterativeDecisionAlgorithm (ArrayParameterSpace branch).
14
+ *
15
+ * @packageDocumentation
16
+ */
17
+ import { East, StructType, VariantType, OptionType, ArrayType, VectorType, IntegerType, BooleanType, FloatType, NullType, FunctionType, } from "@elaraai/east";
18
+ // ============================================================================
19
+ // Type Definitions
20
+ // ============================================================================
21
+ /** Parameter vector: Vector<Integer> */
22
+ export const ParameterVectorType = VectorType(IntegerType);
23
+ /** Objective function: Vector<Integer> -> Float */
24
+ export const IterativeObjectiveType = FunctionType([ParameterVectorType], FloatType);
25
+ /** Per-element candidate spaces: Array<Vector<Integer>> */
26
+ export const ParameterSpacesType = ArrayType(ParameterVectorType);
27
+ /**
28
+ * Initial value strategy for parameters.
29
+ *
30
+ * - `first`: Use the first candidate value from each space
31
+ * - `random`: Randomly select from each space
32
+ */
33
+ export const InitialStrategyType = VariantType({
34
+ first: NullType,
35
+ random: NullType,
36
+ });
37
+ /**
38
+ * Evaluation order for candidate values within each element's space.
39
+ *
40
+ * - `sequential`: Try candidates in the order they appear
41
+ * - `random`: Shuffle candidates before trying
42
+ */
43
+ export const EvaluationOrderType = VariantType({
44
+ sequential: NullType,
45
+ random: NullType,
46
+ });
47
+ /**
48
+ * Optimization mode.
49
+ *
50
+ * - `coordinate`: Standard coordinate descent — optimize each element independently (default)
51
+ * - `swap`: Swap-based moves — swap pairs of elements, preserving valid permutations
52
+ */
53
+ export const ModeType = VariantType({
54
+ coordinate: NullType,
55
+ swap: NullType,
56
+ });
57
+ /**
58
+ * Configuration for iterative optimization.
59
+ *
60
+ * All fields are optional with sensible defaults.
61
+ */
62
+ export const IterativeConfigType = StructType({
63
+ /** Maximum coordinate descent iterations per sample (default: 100) */
64
+ iterations: OptionType(IntegerType),
65
+ /** Number of independent restarts (default: 1) */
66
+ samples: OptionType(IntegerType),
67
+ /** How to initialize parameter values (default: first) */
68
+ initial: OptionType(InitialStrategyType),
69
+ /** Order to evaluate candidates (default: sequential) */
70
+ order: OptionType(EvaluationOrderType),
71
+ /** Random seed for reproducibility */
72
+ random_state: OptionType(IntegerType),
73
+ /** Optimization mode: coordinate (default) or swap for permutations */
74
+ mode: OptionType(ModeType),
75
+ });
76
+ /**
77
+ * Result of iterative optimization.
78
+ */
79
+ export const IterativeResultType = StructType({
80
+ /** Best parameter values found */
81
+ best_parameters: ParameterVectorType,
82
+ /** Objective value at best parameters */
83
+ best_objective: FloatType,
84
+ /** Total coordinate descent iterations across all samples */
85
+ iterations: IntegerType,
86
+ /** Total number of objective evaluations */
87
+ evaluations: IntegerType,
88
+ /** Whether optimization succeeded */
89
+ success: BooleanType,
90
+ });
91
+ // ============================================================================
92
+ // Platform Functions
93
+ // ============================================================================
94
+ /**
95
+ * Iterative optimization over integer parameter vectors.
96
+ *
97
+ * Maximizes an objective function over a vector of discrete integer parameters.
98
+ * Each parameter position has its own set of candidate values (vector).
99
+ *
100
+ * Two modes are available:
101
+ * - **coordinate** (default): Coordinate descent — optimizes each element independently
102
+ * by trying all candidate values while holding others fixed. Best for assignment problems
103
+ * where each position can take any value independently.
104
+ * - **swap**: Swap-based moves — swaps pairs of elements, preserving valid permutations.
105
+ * Use this for permutation problems (scheduling, ordering) where each value must appear
106
+ * exactly once.
107
+ *
108
+ * @example Coordinate mode (assignment)
109
+ * ```ts
110
+ * const config = $.let({
111
+ * iterations: variant('some', 10n),
112
+ * samples: variant('some', 3n),
113
+ * initial: variant('some', variant('random', null)),
114
+ * order: variant('some', variant('sequential', null)),
115
+ * random_state: variant('some', 42n),
116
+ * mode: variant('none', null), // coordinate is the default
117
+ * });
118
+ * const result = $.let(Optimization.iterative(objective, spaces, config));
119
+ * ```
120
+ *
121
+ * @example Swap mode (permutation)
122
+ * ```ts
123
+ * const config = $.let({
124
+ * iterations: variant('some', 50n),
125
+ * samples: variant('some', 10n),
126
+ * initial: variant('some', variant('random', null)),
127
+ * order: variant('some', variant('random', null)),
128
+ * random_state: variant('some', 42n),
129
+ * mode: variant('some', variant('swap', null)),
130
+ * });
131
+ * const result = $.let(Optimization.iterative(objective, spaces, config));
132
+ * ```
133
+ */
134
+ export const optimization_iterative = East.platform("optimization_iterative", [
135
+ IterativeObjectiveType, // objective: Vector<Integer> -> Float
136
+ ParameterSpacesType, // parameter_spaces: Array<Vector<Integer>>
137
+ IterativeConfigType, // config
138
+ ], IterativeResultType);
139
+ // ============================================================================
140
+ // Grouped Export
141
+ // ============================================================================
142
+ /**
143
+ * Type definitions for iterative optimization.
144
+ */
145
+ export const OptimizationTypes = {
146
+ /** Parameter vector type */
147
+ ParameterVectorType,
148
+ /** Objective function type */
149
+ ObjectiveType: IterativeObjectiveType,
150
+ /** Parameter spaces type */
151
+ SpacesType: ParameterSpacesType,
152
+ /** Initial value strategy variant */
153
+ InitialStrategyType,
154
+ /** Evaluation order variant */
155
+ EvaluationOrderType,
156
+ /** Optimization mode variant */
157
+ ModeType,
158
+ /** Configuration type */
159
+ ConfigType: IterativeConfigType,
160
+ /** Result type */
161
+ ResultType: IterativeResultType,
162
+ };
163
+ /**
164
+ * Iterative optimization for discrete combinatorial problems.
165
+ *
166
+ * Supports two modes:
167
+ * - **coordinate** (default): Element-wise coordinate descent. Best for
168
+ * assignment problems where positions are independent.
169
+ * - **swap**: Pair-wise swap moves preserving permutations. Best for
170
+ * scheduling/ordering where each value must appear exactly once.
171
+ *
172
+ * Use cases:
173
+ * - Task-worker assignment (coordinate mode)
174
+ * - Scheduling and ordering (swap mode)
175
+ * - Combinatorial selection problems
176
+ * - Any discrete optimization with per-element candidate sets
177
+ */
178
+ export const Optimization = {
179
+ /**
180
+ * Iterative optimization over integer parameter vectors.
181
+ *
182
+ * `Optimization.iterative(objective, spaces, config)`
183
+ *
184
+ * @example Coordinate mode — task-worker assignment
185
+ * ```ts
186
+ * // 3 tasks, 2 workers. Maximize total skill match.
187
+ * const skill = $.let([[3.0, 1.0], [1.0, 3.0], [2.0, 2.0]]);
188
+ * const objective = East.function(
189
+ * [VectorType(IntegerType)], FloatType,
190
+ * ($, assignments) => {
191
+ * const total = $.let(0.0);
192
+ * $.for(East.Array.range(0n, East.value(3n)), ($, i) => {
193
+ * $.assign(total, total.add(skill.get(i).get(assignments.get(i))));
194
+ * });
195
+ * return $.return(total);
196
+ * }
197
+ * );
198
+ * const spaces = $.let([
199
+ * new BigInt64Array([0n, 1n]),
200
+ * new BigInt64Array([0n, 1n]),
201
+ * new BigInt64Array([0n, 1n]),
202
+ * ]);
203
+ * const config = $.let({
204
+ * iterations: variant('some', 10n),
205
+ * samples: variant('some', 3n),
206
+ * initial: variant('some', variant('random', null)),
207
+ * order: variant('some', variant('sequential', null)),
208
+ * random_state: variant('some', 42n),
209
+ * mode: variant('none', null),
210
+ * });
211
+ * const result = $.let(Optimization.iterative(objective, spaces, config));
212
+ * // result.best_objective = 8.0 (task 0→worker 0, task 1→worker 1, task 2→either)
213
+ * ```
214
+ *
215
+ * @example Swap mode — scheduling permutation
216
+ * ```ts
217
+ * // 4 jobs: find execution order minimizing weighted completion time.
218
+ * const durations = $.let([10.0, 5.0, 20.0, 3.0]);
219
+ * const values = $.let([1.0, 8.0, 2.0, 10.0]);
220
+ * const objective = East.function(
221
+ * [VectorType(IntegerType)], FloatType,
222
+ * ($, perm) => {
223
+ * const cum = $.let(0.0);
224
+ * const total = $.let(0.0);
225
+ * $.for(East.Array.range(0n, East.value(4n)), ($, i) => {
226
+ * const idx = $.let(perm.get(i));
227
+ * $.assign(cum, cum.add(durations.get(idx)));
228
+ * $.assign(total, total.add(values.get(idx).multiply(cum)));
229
+ * });
230
+ * return $.return(total.negate());
231
+ * }
232
+ * );
233
+ * const spaces = $.let([
234
+ * new BigInt64Array([0n, 1n, 2n, 3n]),
235
+ * new BigInt64Array([0n, 1n, 2n, 3n]),
236
+ * new BigInt64Array([0n, 1n, 2n, 3n]),
237
+ * new BigInt64Array([0n, 1n, 2n, 3n]),
238
+ * ]);
239
+ * const config = $.let({
240
+ * iterations: variant('some', 50n),
241
+ * samples: variant('some', 10n),
242
+ * initial: variant('some', variant('random', null)),
243
+ * order: variant('some', variant('random', null)),
244
+ * random_state: variant('some', 42n),
245
+ * mode: variant('some', variant('swap', null)),
246
+ * });
247
+ * const result = $.let(Optimization.iterative(objective, spaces, config));
248
+ * // result.best_objective = -188.0 (optimal WSPT order)
249
+ * ```
250
+ */
251
+ iterative: optimization_iterative,
252
+ /**
253
+ * Type definitions for optimization functions.
254
+ */
255
+ Types: OptimizationTypes,
256
+ };
257
+ //# sourceMappingURL=optimization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimization.js","sourceRoot":"","sources":["../../../src/optimization/optimization.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,EACH,IAAI,EACJ,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,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