mex-ml
v0.3.3
Published
A beginner-friendly ML learning language that teaches machine learning through clean, readable code. Zero dependencies.
Maintainers
Readme
MEX — Machine Learning EXpression Language
A beginner-friendly programming language that teaches machine learning concepts through interactive code. Write clean, readable code that converts to real TensorFlow.js or Python.
No dependencies required — includes a minimal neural network built from scratch.
Quick Start (2 minutes)
Install
npm install -g mex-mlCreate Your First Project
mex init my-first-ml
cd my-first-ml
mex run hello.mxThat's It!
You now have a working ML project with:
hello.mx— your first programexamples/— example filesdatasets/— your data filesREADME.md— documentation
Features
- Simple Syntax — reads like English
- Zero Dependencies — runs anywhere Node.js runs
- 100+ Built-in Functions — math, statistics, arrays, strings, data
- DataFrame API — Pandas-like data manipulation with method chaining
- Visualization — ASCII charts (bar, line, scatter, histogram, pie)
- Dual Export — generate TensorFlow.js or Python code
- Smart Debug — catches NaN, exploding loss, overfitting
- Interactive Playground — web-based editor with syntax highlighting
- REPL Mode — interactive command line for experimenting
- Type System — optional type annotations with runtime checking
- Package Manager — install and share MEX packages
- Learning System — 6 lessons, challenges, achievements
Commands
Getting Started
mex init <project> # Create new project
mex new <name> # Create new .mx file
mex run <file.mx> # Run a .mx file
mex repl # Start interactive REPL
mex --help # Show all commands
mex --version # Show versionLearning
mex lesson 1 # Start lesson 1
mex challenge 1 # Try challenge 1
mex lessons # List all lessons
mex status # Check your progress
mex achievements # View achievementsCode Generation
mex --generate file.mx # Generate TensorFlow.js
mex --python file.mx # Generate Python
mex --show-tf file.mx # Show TF.js alongside
mex --stats file.mx # Show compression statsExample: Linear Regression
Write MEX Code
data points
(1, 2)
(2, 4)
(3, 6)
(4, 8)
model simple
train 100 epochs
predict 5Run It
mex run hello.mxOutput
Data loaded: 4 points
Model created: simple (linear)
Training for 100 epochs...
Training complete! Error: 0.001234
Prediction for 5: 9.9876Convert to Python
mex --python hello.mx# Generated by MEX → Python/TensorFlow
import tensorflow as tf
import numpy as np
xs = np.array([1, 2, 3, 4]).reshape(-1, 1)
ys = np.array([2, 4, 6, 8]).reshape(-1, 1)
model = tf.keras.Sequential([
tf.keras.layers.Dense(1, input_shape=[1])
])
model.compile(optimizer='sgd', loss='mse')
model.fit(xs, ys, epochs=100, verbose=0)
pred = model.predict(np.array([[5]]))
print(f"Prediction: {pred.numpy()[0][0]:.4f}")Language Syntax
Data
data points (1, 2) (3, 4) # Inline data
data csv "houses.csv" # CSV fileModels
model simple # Linear regression
model sequential # Neural network
dense 8 relu # Hidden layer
dropout 0.2 # Regularization
dense 1 sigmoid # Output layerTraining
train 100 epochs # Basic training
train 200 epochs learning_rate 0.01 # Custom learning ratePrediction
predict 5 # Single value
predict [5, 10, 15] # Multiple valuesControl Flow
if (x > 5) { ... } else { ... }
for i in range(10) { ... }
while (x > 0) { ... }Functions
fn add(a, b) {
return a + b
}
let doubled = map([1, 2, 3], fn(x) { return x * 2 })Type Annotations (Optional)
let x: number = 42
fn add(a: number, b: number) -> number {
return a + b
}DataFrame Chaining
data csv "houses.csv"
let result = data
.filter("size", ">", 2000)
.sort("price", false)
.head(3)
print(result.to_json())Built-in Functions (100+)
Math
sqrt, pow, abs, sin, cos, tan, log, exp, floor, ceil, round, random
Statistics
mean, sum, std, variance, median, mode, min_arr, max_arr
String
len, upper, lower, trim, split, join, replace, includes, type
Array
sort, sort_by, reverse, unique, flatten, slice, head, tail, zip
Higher-Order
map, filter, reduce, each, find, find_index, every, some, group_by
Data
column, columns, select, where, limit, offset, sample, shuffle, distinct
Visualization
bar_chart, line_chart, scatter_plot, histogram, pie_chart
Learning Path
| Lesson | Topic | Duration | |--------|-------|----------| | 1 | What is Data? | 20 min | | 2 | Finding Patterns | 25 min | | 3 | Classification | 25 min | | 4 | Neural Networks | 30 min | | 5 | Real Data | 30 min | | 6 | Advanced Topics | 35 min |
Interactive Playground
Open playground/index.html in your browser:
- Syntax highlighting
- Autocomplete (50+ functions)
- 12 built-in examples
- File tabs with auto-save
- CSV import/export
Documentation
| Document | Description | |----------|-------------| | DOCS.md | Complete language reference | | CHANGES.md | Changelog | | CONTRIBUTING.md | How to contribute |
System Requirements
- Node.js: v14 or higher
- OS: Windows, macOS, Linux
License
MIT License — see LICENSE for details.
Support
- Issues: GitHub Issues
- npm: npmjs.com/package/mex-ml
