Skip to content

Commit 2c52414

Browse files
committed
Add AGENTS.md file
1 parent 9e949c6 commit 2c52414

1 file changed

Lines changed: 93 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Rubix ML — Agent Guide
2+
3+
## Project
4+
5+
High-level machine learning and deep learning library for **PHP 8.3+**. Namespace `Rubix\ML` autoloaded from `src/`. Requires the [Rubix Tensor](https://github.com/RubixML/Tensor) extension for fast matrix/vector operations.
6+
7+
## Key Commands
8+
9+
| Command | Action |
10+
| --- | --- |
11+
| `composer test` | Run PHPUnit tests |
12+
| `composer analyze` | PHPStan static analysis (level 8) |
13+
| `composer check` | PHP-CS-Fixer dry-run (style check) |
14+
| `composer fix` | PHP-CS-Fixer auto-fix |
15+
| `composer phplint` | PHP syntax lint |
16+
| `composer benchmark` | PHPBench benchmarks |
17+
| `composer build` | Full pipeline: install → analyze → test → check |
18+
19+
## Architecture
20+
21+
```
22+
src/ → Rubix\ML\* (PSR-4)
23+
tests/ → Rubix\ML\Tests\* (PHPUnit, mirrors src/)
24+
benchmarks/ → Rubix\ML\Benchmarks\* (PHPBench, mirrors src/)
25+
docs/ → MkDocs documentation
26+
```
27+
28+
### Core Interfaces
29+
30+
`Estimator`, `Learner`, `Online`, `Parallel`, `Probabilistic`, `Persistable`, `Verbose`, `RanksFeatures`, `Scoring`
31+
32+
### Meta-Estimators
33+
34+
`Pipeline`, `GridSearch`, `PersistentModel`, `CommitteeMachine`, `BootstrapAggregator`
35+
36+
### Estimator Types
37+
38+
- **Classifiers** (15): AdaBoost, RandomForest, SVC, LogisticRegression, MLP, KNN, NaiveBayes, etc.
39+
- **Regressors** (10): GradientBoost, Ridge, SVR, RegressionTree, Adaline, KNNRegressor, etc.
40+
- **Clusterers** (5): KMeans, DBSCAN, GaussianMixture, MeanShift, FuzzyCMeans
41+
- **Anomaly Detectors** (7): IsolationForest, LOF, OneClassSVM, GaussianMLE, Loda, RobustZScore
42+
43+
## Code Conventions
44+
45+
- `declare(strict_types=1)` in every file
46+
- PSR-2 with extended rules (enforced by PHP-CS-Fixer, see `.php-cs-fixer.dist.php`)
47+
- DocBlock on every class, property, method, constant, and function
48+
- No anonymous classes or functions (breaks serialization/persistence)
49+
- Objects are *generally* immutable — state mutation only through a well-defined public API
50+
- Domain-driven naming — names reflect the ML domain
51+
- No inline comments — use expressive syntax and abstractions instead
52+
- Named arguments preferred in constructor calls
53+
- Single quotes for strings, short array syntax (`[]`)
54+
- Pre-increment (`++$i`)
55+
- No superfluous `else`/`return` constructs
56+
57+
## Workflows
58+
59+
### Adding a New Estimator
60+
61+
1. Create class in `src/Classifiers/`, `src/Regressors/`, `src/AnomalyDetectors/`, or `src/Clusterers/`
62+
2. Implement the appropriate interface(s) — `Estimator` + `Learner` (or `Online`) at minimum
63+
3. Create PHPUnit test in `tests/` with `#[CoversClass]` attribute
64+
4. For learners: end-to-end test — generate synthetic data, train, validate against minimum score; seed the RNG for determinism
65+
5. Create benchmark in `benchmarks/`
66+
6. Run `composer analyze && composer test && composer check`
67+
7. Add documentation page under `docs/`
68+
69+
### Adding a New Transformer
70+
71+
1. Create class in `src/Transformers/` implementing the `Transformer` interface
72+
2. Create PHPUnit test in `tests/Transformers/`
73+
3. Add documentation page under `docs/transformers/`
74+
75+
### Adding a New Neural Net Component
76+
77+
- Layers → `src/NeuralNet/Layers/`
78+
- Activation functions → `src/NeuralNet/ActivationFunctions/`
79+
- Cost functions → `src/NeuralNet/CostFunctions/`
80+
- Optimizers → `src/NeuralNet/Optimizers/`
81+
- Initializers → `src/NeuralNet/Initializers/`
82+
83+
### Building Documentation
84+
85+
```sh
86+
pip install mike mkdocs mkdocs-material mkdocs-git-revision-date-localized-plugin
87+
mike deploy 'VERSION'
88+
mike serve
89+
```
90+
91+
## CI
92+
93+
GitHub Actions (`.github/workflows/ci.yml`) runs on push/PR: phplint → phpstan → phpunit → php-cs-fixer check.

0 commit comments

Comments
 (0)