@elaraai/east-py-datascience 0.0.2-beta.1

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 (56) hide show
  1. package/LICENSE.md +18 -0
  2. package/README.md +104 -0
  3. package/dist/gp/gp.d.ts +398 -0
  4. package/dist/gp/gp.d.ts.map +1 -0
  5. package/dist/gp/gp.js +170 -0
  6. package/dist/gp/gp.js.map +1 -0
  7. package/dist/index.d.ts +27 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +39 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/lightgbm/lightgbm.d.ts +494 -0
  12. package/dist/lightgbm/lightgbm.d.ts.map +1 -0
  13. package/dist/lightgbm/lightgbm.js +155 -0
  14. package/dist/lightgbm/lightgbm.js.map +1 -0
  15. package/dist/mads/mads.d.ts +413 -0
  16. package/dist/mads/mads.d.ts.map +1 -0
  17. package/dist/mads/mads.js +221 -0
  18. package/dist/mads/mads.js.map +1 -0
  19. package/dist/ngboost/ngboost.d.ts +433 -0
  20. package/dist/ngboost/ngboost.d.ts.map +1 -0
  21. package/dist/ngboost/ngboost.js +178 -0
  22. package/dist/ngboost/ngboost.js.map +1 -0
  23. package/dist/optuna/optuna.d.ts +797 -0
  24. package/dist/optuna/optuna.d.ts.map +1 -0
  25. package/dist/optuna/optuna.js +268 -0
  26. package/dist/optuna/optuna.js.map +1 -0
  27. package/dist/scipy/scipy.d.ts +954 -0
  28. package/dist/scipy/scipy.d.ts.map +1 -0
  29. package/dist/scipy/scipy.js +287 -0
  30. package/dist/scipy/scipy.js.map +1 -0
  31. package/dist/shap/shap.d.ts +657 -0
  32. package/dist/shap/shap.d.ts.map +1 -0
  33. package/dist/shap/shap.js +241 -0
  34. package/dist/shap/shap.js.map +1 -0
  35. package/dist/simanneal/simanneal.d.ts +531 -0
  36. package/dist/simanneal/simanneal.d.ts.map +1 -0
  37. package/dist/simanneal/simanneal.js +231 -0
  38. package/dist/simanneal/simanneal.js.map +1 -0
  39. package/dist/sklearn/sklearn.d.ts +1272 -0
  40. package/dist/sklearn/sklearn.d.ts.map +1 -0
  41. package/dist/sklearn/sklearn.js +307 -0
  42. package/dist/sklearn/sklearn.js.map +1 -0
  43. package/dist/torch/torch.d.ts +658 -0
  44. package/dist/torch/torch.d.ts.map +1 -0
  45. package/dist/torch/torch.js +233 -0
  46. package/dist/torch/torch.js.map +1 -0
  47. package/dist/tsconfig.tsbuildinfo +1 -0
  48. package/dist/types.d.ts +80 -0
  49. package/dist/types.d.ts.map +1 -0
  50. package/dist/types.js +81 -0
  51. package/dist/types.js.map +1 -0
  52. package/dist/xgboost/xgboost.d.ts +504 -0
  53. package/dist/xgboost/xgboost.d.ts.map +1 -0
  54. package/dist/xgboost/xgboost.js +177 -0
  55. package/dist/xgboost/xgboost.js.map +1 -0
  56. package/package.json +82 -0
@@ -0,0 +1,177 @@
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
+ * XGBoost platform functions for East.
7
+ *
8
+ * Provides gradient boosting for regression and classification.
9
+ * Uses ONNX for model serialization to enable portable inference.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ import { East, StructType, VariantType, OptionType, IntegerType, FloatType, BlobType, } from "@elaraai/east";
14
+ import { VectorType, MatrixType, LabelVectorType } from "../types.js";
15
+ // Re-export shared types for convenience
16
+ export { VectorType, MatrixType, LabelVectorType } from "../types.js";
17
+ // ============================================================================
18
+ // Config Types
19
+ // ============================================================================
20
+ /**
21
+ * Configuration for XGBoost models.
22
+ */
23
+ export const XGBoostConfigType = StructType({
24
+ /** Number of boosting rounds (default 100) */
25
+ n_estimators: OptionType(IntegerType),
26
+ /** Maximum tree depth (default 6) */
27
+ max_depth: OptionType(IntegerType),
28
+ /** Learning rate / step size shrinkage (default 0.3) */
29
+ learning_rate: OptionType(FloatType),
30
+ /** Minimum sum of instance weight needed in a child (default 1) */
31
+ min_child_weight: OptionType(IntegerType),
32
+ /** Subsample ratio of training instances (default 1.0) */
33
+ subsample: OptionType(FloatType),
34
+ /** Subsample ratio of columns when constructing trees (default 1.0) */
35
+ colsample_bytree: OptionType(FloatType),
36
+ /** L1 regularization term (default 0) */
37
+ reg_alpha: OptionType(FloatType),
38
+ /** L2 regularization term (default 1) */
39
+ reg_lambda: OptionType(FloatType),
40
+ /** Random seed for reproducibility */
41
+ random_state: OptionType(IntegerType),
42
+ /** Number of parallel threads (default -1 for all cores) */
43
+ n_jobs: OptionType(IntegerType),
44
+ });
45
+ // ============================================================================
46
+ // Model Blob Types
47
+ // ============================================================================
48
+ /**
49
+ * Model blob type for serialized XGBoost models.
50
+ *
51
+ * Each model type has its own variant case containing cloudpickle bytes and metadata.
52
+ */
53
+ export const XGBoostModelBlobType = VariantType({
54
+ /** XGBoost regressor model */
55
+ xgboost_regressor: StructType({
56
+ /** Cloudpickle serialized model */
57
+ data: BlobType,
58
+ /** Number of input features */
59
+ n_features: IntegerType,
60
+ }),
61
+ /** XGBoost classifier model */
62
+ xgboost_classifier: StructType({
63
+ /** Cloudpickle serialized model */
64
+ data: BlobType,
65
+ /** Number of input features */
66
+ n_features: IntegerType,
67
+ /** Number of classes */
68
+ n_classes: IntegerType,
69
+ }),
70
+ });
71
+ // ============================================================================
72
+ // Platform Functions
73
+ // ============================================================================
74
+ /**
75
+ * Train an XGBoost regression model.
76
+ *
77
+ * @param X - Feature matrix
78
+ * @param y - Target vector
79
+ * @param config - XGBoost configuration
80
+ * @returns Model blob containing trained regressor
81
+ */
82
+ export const xgboost_train_regressor = East.platform("xgboost_train_regressor", [MatrixType, VectorType, XGBoostConfigType], XGBoostModelBlobType);
83
+ /**
84
+ * Train an XGBoost classification model.
85
+ *
86
+ * @param X - Feature matrix
87
+ * @param y - Label vector (integer class labels)
88
+ * @param config - XGBoost configuration
89
+ * @returns Model blob containing trained classifier
90
+ */
91
+ export const xgboost_train_classifier = East.platform("xgboost_train_classifier", [MatrixType, LabelVectorType, XGBoostConfigType], XGBoostModelBlobType);
92
+ /**
93
+ * Make predictions with a trained XGBoost regressor.
94
+ *
95
+ * @param model - Trained regressor model blob
96
+ * @param X - Feature matrix
97
+ * @returns Predicted values
98
+ */
99
+ export const xgboost_predict = East.platform("xgboost_predict", [XGBoostModelBlobType, MatrixType], VectorType);
100
+ /**
101
+ * Predict class labels with a trained XGBoost classifier.
102
+ *
103
+ * @param model - Trained classifier model blob
104
+ * @param X - Feature matrix
105
+ * @returns Predicted class labels
106
+ */
107
+ export const xgboost_predict_class = East.platform("xgboost_predict_class", [XGBoostModelBlobType, MatrixType], LabelVectorType);
108
+ /**
109
+ * Get class probabilities from a trained XGBoost classifier.
110
+ *
111
+ * @param model - Trained classifier model blob
112
+ * @param X - Feature matrix
113
+ * @returns Probability matrix (n_samples x n_classes)
114
+ */
115
+ export const xgboost_predict_proba = East.platform("xgboost_predict_proba", [XGBoostModelBlobType, MatrixType], MatrixType);
116
+ // ============================================================================
117
+ // Grouped Export
118
+ // ============================================================================
119
+ /**
120
+ * Type definitions for XGBoost functions.
121
+ */
122
+ export const XGBoostTypes = {
123
+ /** Vector type (array of floats) */
124
+ VectorType,
125
+ /** Matrix type (2D array of floats) */
126
+ MatrixType,
127
+ /** Label vector type (array of integers) */
128
+ LabelVectorType,
129
+ /** XGBoost configuration type */
130
+ XGBoostConfigType,
131
+ /** Model blob type for XGBoost models */
132
+ ModelBlobType: XGBoostModelBlobType,
133
+ };
134
+ /**
135
+ * XGBoost gradient boosting.
136
+ *
137
+ * Provides regression and classification with gradient boosted decision trees.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * import { East, variant } from "@elaraai/east";
142
+ * import { XGBoost } from "@elaraai/east-py-datascience";
143
+ *
144
+ * const train = East.function([], XGBoost.Types.ModelBlobType, $ => {
145
+ * const X = $.let([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0], [7.0, 8.0]]);
146
+ * const y = $.let([1.0, 2.0, 3.0, 4.0]);
147
+ * const config = $.let({
148
+ * n_estimators: variant('some', 100n),
149
+ * max_depth: variant('some', 3n),
150
+ * learning_rate: variant('some', 0.1),
151
+ * min_child_weight: variant('none', null),
152
+ * subsample: variant('none', null),
153
+ * colsample_bytree: variant('none', null),
154
+ * reg_alpha: variant('none', null),
155
+ * reg_lambda: variant('none', null),
156
+ * random_state: variant('some', 42n),
157
+ * n_jobs: variant('none', null),
158
+ * });
159
+ * return $.return(XGBoost.trainRegressor(X, y, config));
160
+ * });
161
+ * ```
162
+ */
163
+ export const XGBoost = {
164
+ /** Train XGBoost regressor */
165
+ trainRegressor: xgboost_train_regressor,
166
+ /** Train XGBoost classifier */
167
+ trainClassifier: xgboost_train_classifier,
168
+ /** Make predictions with regressor */
169
+ predict: xgboost_predict,
170
+ /** Predict class labels with classifier */
171
+ predictClass: xgboost_predict_class,
172
+ /** Get class probabilities from classifier */
173
+ predictProba: xgboost_predict_proba,
174
+ /** Type definitions */
175
+ Types: XGBoostTypes,
176
+ };
177
+ //# sourceMappingURL=xgboost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xgboost.js","sourceRoot":"","sources":["../../src/xgboost/xgboost.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EACH,IAAI,EACJ,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,SAAS,EACT,QAAQ,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEtE,yCAAyC;AACzC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEtE,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;IACxC,8CAA8C;IAC9C,YAAY,EAAE,UAAU,CAAC,WAAW,CAAC;IACrC,qCAA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3
+ "version": "0.0.2-beta.1",
4
+ "description": "East Data Science - ML/optimization platform functions for East (TypeScript definitions)",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "!dist/**/*.spec.*",
16
+ "README.md",
17
+ "LICENSE.md",
18
+ "CONTRIBUTING.md",
19
+ "CLA.md"
20
+ ],
21
+ "scripts": {
22
+ "build": "tsc",
23
+ "test": "npm run build && node --enable-source-maps --test 'dist/**/*.spec.js'",
24
+ "test:coverage": "npm run build && node --enable-source-maps --test --experimental-test-coverage 'dist/**/*.spec.js'",
25
+ "test:export": "npm run build && EXPORT_TEST_IR=/tmp/east-py-datascience npm test 2>&1 | grep 'Exported test IR'",
26
+ "lint": "eslint .",
27
+ "lint:fix": "eslint . --fix",
28
+ "version:patch": "npm version patch -m 'chore: bump version to %s'",
29
+ "version:minor": "npm version minor -m 'chore: bump version to %s'",
30
+ "version:major": "npm version major -m 'chore: bump version to %s'",
31
+ "version:prepatch": "npm version prepatch --preid=beta -m 'chore: bump version to %s'",
32
+ "version:preminor": "npm version preminor --preid=beta -m 'chore: bump version to %s'",
33
+ "version:premajor": "npm version premajor --preid=beta -m 'chore: bump version to %s'",
34
+ "version:prerelease": "npm version prerelease --preid=beta -m 'chore: bump version to %s'",
35
+ "version:patch:dry": "npm version patch --no-git-tag-version",
36
+ "version:minor:dry": "npm version minor --no-git-tag-version",
37
+ "version:major:dry": "npm version major --no-git-tag-version",
38
+ "version:prepatch:dry": "npm version prepatch --preid=beta --no-git-tag-version",
39
+ "version:preminor:dry": "npm version preminor --preid=beta --no-git-tag-version",
40
+ "version:premajor:dry": "npm version premajor --preid=beta --no-git-tag-version",
41
+ "version:prerelease:dry": "npm version prerelease --preid=beta --no-git-tag-version",
42
+ "release:patch": "npm run version:patch && git push && git push --tags",
43
+ "release:minor": "npm run version:minor && git push && git push --tags",
44
+ "release:major": "npm run version:major && git push && git push --tags",
45
+ "release:prepatch": "npm run version:prepatch && git push && git push --tags",
46
+ "release:preminor": "npm run version:preminor && git push && git push --tags",
47
+ "release:premajor": "npm run version:premajor && git push && git push --tags",
48
+ "release:prerelease": "npm run version:prerelease && git push && git push --tags"
49
+ },
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "https://github.com/elaraai/east-py.git",
53
+ "directory": "packages/east-py-datascience"
54
+ },
55
+ "keywords": [
56
+ "east",
57
+ "elara",
58
+ "datascience",
59
+ "ml",
60
+ "optimization",
61
+ "mads",
62
+ "pynomad"
63
+ ],
64
+ "author": "Elara AI Pty Ltd",
65
+ "license": "SEE LICENSE IN LICENSE",
66
+ "type": "module",
67
+ "engines": {
68
+ "node": ">=22.0.0"
69
+ },
70
+ "devDependencies": {
71
+ "@types/node": "^22.18.1",
72
+ "@typescript-eslint/eslint-plugin": "^8.42.0",
73
+ "@typescript-eslint/parser": "^8.42.0",
74
+ "eslint": "^9.34.0",
75
+ "eslint-plugin-headers": "^1.3.3",
76
+ "typescript": "~5.9.2"
77
+ },
78
+ "dependencies": {
79
+ "@elaraai/east": "^0.0.1-beta.5",
80
+ "@elaraai/east-node-std": "^0.0.1-beta.4"
81
+ }
82
+ }