@codin-io/mlxd 1.0.17

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.

Potentially problematic release.


This version of @codin-io/mlxd might be problematic. Click here for more details.

@@ -0,0 +1,6 @@
1
+ /* @license
2
+ Papa Parse
3
+ v5.4.1
4
+ https://github.com/mholt/PapaParse
5
+ License: MIT
6
+ */
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env python3
2
+ import sys
3
+ import json
4
+ import numpy as np
5
+ from sklearn.metrics import accuracy_score, f1_score, mean_squared_error
6
+
7
+ # Optional: import real ML libraries
8
+ # from transformers import AutoModelForSequenceClassification, AutoTokenizer
9
+ # import torch
10
+
11
+
12
+ def load_dataset(data_path: str):
13
+ # Replace this logic to load an actual dataset (CSV, JSON, etc.)
14
+ # Here, we're just simulating random predictions & labels for demo purposes.
15
+ preds = np.random.randint(0, 2, 100)
16
+ labels = np.random.randint(0, 2, 100)
17
+ return preds, labels
18
+
19
+
20
+ def validate_dataset(preds, labels):
21
+ # Example: Check if we got enough samples or if data is empty.
22
+ if len(preds) == 0 or len(labels) == 0:
23
+ return False, "No data found for predictions or labels."
24
+ if len(preds) != len(labels):
25
+ return False, "Predictions and labels have different lengths."
26
+ return True, ""
27
+
28
+
29
+ def load_model(model_path: str):
30
+ # In a real scenario, load your ML model here (e.g., GPT-Neo, BERT).
31
+ # Example (commented out):
32
+ # model = AutoModelForSequenceClassification.from_pretrained(model_path)
33
+ # tokenizer = AutoTokenizer.from_pretrained(model_path)
34
+ return None
35
+
36
+
37
+ def main():
38
+ # CLI arguments:
39
+ # 1) Metric name (e.g., "accuracy", "f1", "rmse").
40
+ # 2) Optional dataset path (default: "my_real_dataset.csv").
41
+ # 3) Optional model path (default: None).
42
+ metric_name = sys.argv[1] if len(sys.argv) > 1 else "accuracy"
43
+ data_path = sys.argv[2] if len(sys.argv) > 2 else "my_real_dataset.csv"
44
+ model_path = sys.argv[3] if len(sys.argv) > 3 else None
45
+
46
+ # Load data (predictions & labels) and validate.
47
+ preds, labels = load_dataset(data_path)
48
+ passed, message = validate_dataset(preds, labels)
49
+ if not passed:
50
+ print(json.dumps({"error": f"Data validation failed: {message}"}))
51
+ sys.exit(1)
52
+
53
+ # Load the model if needed (inference logic not shown in this sample).
54
+ model = load_model(model_path)
55
+
56
+ # Calculate the requested metric.
57
+ if metric_name == "accuracy":
58
+ value = accuracy_score(labels, preds)
59
+ elif metric_name == "f1":
60
+ value = f1_score(labels, preds)
61
+ elif metric_name == "rmse":
62
+ value = mean_squared_error(labels, preds, squared=False)
63
+ else:
64
+ value = 0.0
65
+
66
+ # Output metric as JSON for the CLI to parse.
67
+ print(json.dumps({"metric": metric_name, "value": float(value)}))
68
+
69
+
70
+ if __name__ == "__main__":
71
+ main()
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env python3
2
+ import sys
3
+ import json
4
+ import numpy as np
5
+ from sklearn.metrics import accuracy_score, f1_score, mean_squared_error
6
+
7
+ # Optional: import real ML libraries
8
+ # from transformers import AutoModelForSequenceClassification, AutoTokenizer
9
+ # import torch
10
+
11
+
12
+ def load_dataset(data_path: str):
13
+ # Replace this logic to load an actual dataset (CSV, JSON, etc.)
14
+ # Here, we're just simulating random predictions & labels for demo purposes.
15
+ preds = np.random.randint(0, 2, 100)
16
+ labels = np.random.randint(0, 2, 100)
17
+ return preds, labels
18
+
19
+
20
+ def validate_dataset(preds, labels):
21
+ # Example: Check if we got enough samples or if data is empty.
22
+ if len(preds) == 0 or len(labels) == 0:
23
+ return False, "No data found for predictions or labels."
24
+ if len(preds) != len(labels):
25
+ return False, "Predictions and labels have different lengths."
26
+ return True, ""
27
+
28
+
29
+ def load_model(model_path: str):
30
+ # In a real scenario, load your ML model here (e.g., GPT-Neo, BERT).
31
+ # Example (commented out):
32
+ # model = AutoModelForSequenceClassification.from_pretrained(model_path)
33
+ # tokenizer = AutoTokenizer.from_pretrained(model_path)
34
+ return None
35
+
36
+
37
+ def main():
38
+ # CLI arguments:
39
+ # 1) Metric name (e.g., "accuracy", "f1", "rmse").
40
+ # 2) Optional dataset path (default: "my_real_dataset.csv").
41
+ # 3) Optional model path (default: None).
42
+ metric_name = sys.argv[1] if len(sys.argv) > 1 else "accuracy"
43
+ data_path = sys.argv[2] if len(sys.argv) > 2 else "my_real_dataset.csv"
44
+ model_path = sys.argv[3] if len(sys.argv) > 3 else None
45
+
46
+ # Load data (predictions & labels) and validate.
47
+ preds, labels = load_dataset(data_path)
48
+ passed, message = validate_dataset(preds, labels)
49
+ if not passed:
50
+ print(json.dumps({"error": f"Data validation failed: {message}"}))
51
+ sys.exit(1)
52
+
53
+ # Load the model if needed (inference logic not shown in this sample).
54
+ model = load_model(model_path)
55
+
56
+ # Calculate the requested metric.
57
+ if metric_name == "accuracy":
58
+ value = accuracy_score(labels, preds)
59
+ elif metric_name == "f1":
60
+ value = f1_score(labels, preds)
61
+ elif metric_name == "rmse":
62
+ value = mean_squared_error(labels, preds, squared=False)
63
+ else:
64
+ value = 0.0
65
+
66
+ # Output metric as JSON for the CLI to parse.
67
+ print(json.dumps({"metric": metric_name, "value": float(value)}))
68
+
69
+
70
+ if __name__ == "__main__":
71
+ main()
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@codin-io/mlxd",
3
+ "version": "1.0.17",
4
+ "description": "CI/CD Testing Tool for ML",
5
+ "author": "codin.io",
6
+ "license": "ISC",
7
+ "main": "mlxd/index.js",
8
+ "bin": {
9
+ "mlxd": "mlxd/index.bundle.js"
10
+ },
11
+ "scripts": {
12
+ "build": "webpack && cp -r python mlxd/python && cp config.yaml mlxd/ && cp README.md mlxd/",
13
+ "test": "jest",
14
+ "postbuild": "node add-shebang.js",
15
+ "prepublishOnly": "npm run build",
16
+ "dev": "ts-node src/index.ts",
17
+ "postinstall": "node scripts/moveMlxd.js"
18
+ },
19
+ "files": [
20
+ "mlxd/**/*",
21
+ "python/**/*",
22
+ "config.yaml",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "devDependencies": {
27
+ "@types/axios": "^0.14.4",
28
+ "@types/dotenv": "^8.2.3",
29
+ "@types/jest": "^29.5.14",
30
+ "@types/js-yaml": "^4.0.9",
31
+ "@types/markdown-pdf": "^9.0.5",
32
+ "@types/mocha": "^10.0.10",
33
+ "@types/node": "^22.10.2",
34
+ "@types/nodemailer": "^6.4.17",
35
+ "@types/papaparse": "^5.3.15",
36
+ "jest": "^29.7.0",
37
+ "terser": "^5.37.0",
38
+ "terser-webpack-plugin": "^5.3.11",
39
+ "ts-jest": "^29.2.5",
40
+ "ts-loader": "^9.5.1",
41
+ "ts-node": "^10.9.2",
42
+ "typescript": "^4.7.4",
43
+ "webpack": "^5.97.1",
44
+ "webpack-cli": "^6.0.1",
45
+ "webpack-obfuscator": "^3.5.1"
46
+ },
47
+ "dependencies": {
48
+ "axios": "^1.7.9",
49
+ "dotenv": "^16.4.7",
50
+ "handlebars": "^4.7.8",
51
+ "js-yaml": "^4.1.0",
52
+ "markdown-pdf": "^11.0.0",
53
+ "nodemailer": "^6.9.16",
54
+ "papaparse": "^5.4.1"
55
+ }
56
+ }
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env python3
2
+ import sys
3
+ import json
4
+ import numpy as np
5
+ from sklearn.metrics import accuracy_score, f1_score, mean_squared_error
6
+
7
+ # Optional: import real ML libraries
8
+ # from transformers import AutoModelForSequenceClassification, AutoTokenizer
9
+ # import torch
10
+
11
+
12
+ def load_dataset(data_path: str):
13
+ # Replace this logic to load an actual dataset (CSV, JSON, etc.)
14
+ # Here, we're just simulating random predictions & labels for demo purposes.
15
+ preds = np.random.randint(0, 2, 100)
16
+ labels = np.random.randint(0, 2, 100)
17
+ return preds, labels
18
+
19
+
20
+ def validate_dataset(preds, labels):
21
+ # Example: Check if we got enough samples or if data is empty.
22
+ if len(preds) == 0 or len(labels) == 0:
23
+ return False, "No data found for predictions or labels."
24
+ if len(preds) != len(labels):
25
+ return False, "Predictions and labels have different lengths."
26
+ return True, ""
27
+
28
+
29
+ def load_model(model_path: str):
30
+ # In a real scenario, load your ML model here (e.g., GPT-Neo, BERT).
31
+ # Example (commented out):
32
+ # model = AutoModelForSequenceClassification.from_pretrained(model_path)
33
+ # tokenizer = AutoTokenizer.from_pretrained(model_path)
34
+ return None
35
+
36
+
37
+ def main():
38
+ # CLI arguments:
39
+ # 1) Metric name (e.g., "accuracy", "f1", "rmse").
40
+ # 2) Optional dataset path (default: "my_real_dataset.csv").
41
+ # 3) Optional model path (default: None).
42
+ metric_name = sys.argv[1] if len(sys.argv) > 1 else "accuracy"
43
+ data_path = sys.argv[2] if len(sys.argv) > 2 else "my_real_dataset.csv"
44
+ model_path = sys.argv[3] if len(sys.argv) > 3 else None
45
+
46
+ # Load data (predictions & labels) and validate.
47
+ preds, labels = load_dataset(data_path)
48
+ passed, message = validate_dataset(preds, labels)
49
+ if not passed:
50
+ print(json.dumps({"error": f"Data validation failed: {message}"}))
51
+ sys.exit(1)
52
+
53
+ # Load the model if needed (inference logic not shown in this sample).
54
+ model = load_model(model_path)
55
+
56
+ # Calculate the requested metric.
57
+ if metric_name == "accuracy":
58
+ value = accuracy_score(labels, preds)
59
+ elif metric_name == "f1":
60
+ value = f1_score(labels, preds)
61
+ elif metric_name == "rmse":
62
+ value = mean_squared_error(labels, preds, squared=False)
63
+ else:
64
+ value = 0.0
65
+
66
+ # Output metric as JSON for the CLI to parse.
67
+ print(json.dumps({"metric": metric_name, "value": float(value)}))
68
+
69
+
70
+ if __name__ == "__main__":
71
+ main()