Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b6846e1
Add data subdirectory to .gitignore
ashwinmathi Feb 11, 2026
02a926c
Add flake.nix for dev environment setup
ashwinmathi Feb 11, 2026
753b827
Add Example.hs for manual testing
ashwinmathi Feb 11, 2026
359f5d3
Refactor: Use GADTs for tagged operations in symbolic regression
ashwinmathi Feb 11, 2026
872da2a
Bump DataFrame to 0.4.1 to get prettyprint for Example.hs and clean u…
ashwinmathi Feb 11, 2026
80f756b
Add optional seed to RegressionConfig for testability
ashwinmathi Feb 11, 2026
6227dee
Refactored eGraphGP for readability
ashwinmathi Feb 11, 2026
c317763
Updated example code name
ashwinmathi Feb 11, 2026
61046e5
Cleanup
ashwinmathi Feb 11, 2026
cbdd3b9
Removed unnecessary GADTs for UnaryFunc and BinaryFunc
ashwinmathi Feb 11, 2026
07aad9b
Defined types for unary and binary operation names
ashwinmathi Feb 11, 2026
b347631
Update haddock documentation for BinaryFunc, add convenience function…
ashwinmathi Feb 12, 2026
cd25a2f
Update README.md with fixed example and optional nix instructions
ashwinmathi Feb 12, 2026
bc952a8
Remove unrunnable Example.hs
ashwinmathi Feb 12, 2026
f9aa0ac
Update .cabal file: Add dependencies to test-suite stanza and remove …
ashwinmathi Feb 12, 2026
cdda61a
Export functions for UnaryFunc and BinaryFunc from Symbolic.Regression
ashwinmathi Feb 12, 2026
421bfde
Add basic tests to validate discovery of constant, linear, quadratic,…
ashwinmathi Feb 12, 2026
015fb6b
Update UnaryFunc/BinaryFunc haddocks to use convenience constructors
ashwinmathi Feb 12, 2026
741bae0
Add nixfmt to flake devShell
ashwinmathi Feb 12, 2026
206b330
Fix haddock example in Symbolic.Regression
ashwinmathi Feb 12, 2026
7ecdcf2
Define default regression config for tests with disabled tracing and …
ashwinmathi Feb 12, 2026
6a46c1c
Refactor tests, use deriveWithExpr when calculating maxAbsError betwe…
ashwinmathi Feb 12, 2026
d9b6469
Refactor egraphGP function by extracting crossover, core evolution lo…
ashwinmathi Feb 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ bin/
coverage-html
.DS_Store
flake.lock
data/
37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ symbolic-regression integrates symbolic regression capabilities into a DataFrame

```haskell
ghci> import qualified DataFrame as D
ghci> import DataFrame.Functions ((.=))
ghci> import qualified DataFrame.Functions as F
ghci> import Symbolic.Regression

-- Load your data
ghci> df <- D.readParquet "./data/mtcars.parquet"

-- Define mpg as a column reference
ghci> let mpg = F.col "mpg"

-- Run symbolic regression to predict 'mpg'
-- NOTE: ALL COLUMNS MUST BE CONVERTED TO DOUBLE FIRST
-- e.g df' = D.derive "some_column" (F.toDouble (F.col @Int "some_column")) df
Expand All @@ -24,19 +27,20 @@ ghci> df <- D.readParquet "./data/mtcars.parquet"
ghci> exprs <- fit defaultRegressionConfig mpg df

-- View discovered expressions (Pareto front from simplest to most complex)
ghci> map D.prettyPrint exprs
-- [ qsec,
-- , 57.33 / wt
-- , 10.75 + (1557.67 / disp)]
ghci> mapM_ (\(i, e) -> putStrLn $ "Model " ++ show i ++ ": " ++ D.prettyPrint e) (zip [1..] exprs)

-- Create named expressions for different complexity levels
ghci> import qualified Data.Text as T
ghci> let levels = zipWith (F..=) (map (T.pack . ("level_" ++) . show) [1..]) exprs

-- Create named expressions that we'll use in a dataframe.
ghci> levels = zipWith (.=) ["level_1", "level_2", "level_3"] exprs
-- Show the various predictions in our dataframe
ghci> let df' = D.deriveMany levels df

-- Show the various predictions in our dataframe.
ghci> D.deriveMany levels df
-- Or pick the best one for prediction
ghci> let df'' = D.derive "prediction" (last exprs) df'

-- Or pick the best one
ghci> D.derive "prediction" (last exprs) df
-- Display the results
ghci> D.display (D.DisplayOptions 5) df''
```

## Configuration
Expand Down Expand Up @@ -102,3 +106,14 @@ To install symbolic-regression you'll need:
* libz: `sudo apt install libz-dev`
* libnlopt: `sudo apt install libnlopt-dev`
* libgmp: `sudo apt install libgmp-dev`

### Nix Development Environment
For Nix users with flakes enabled:

```bash
git clone <repo-url>
cd symbolic-regression
nix develop -c cabal repl
```

Then follow the Quick Start example above.
84 changes: 84 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
description = "DataFrame symbolic regression";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
};

outputs =
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
];

perSystem =
{
config,
pkgs,
system,
...
}:
let
pkgs' = import inputs.nixpkgs {
inherit system;
config.allowBroken = true;
};

haskellPackages = pkgs'.haskellPackages.extend (
final: prev: {
# Use the correct hash that Nix gave us
random = pkgs'.haskell.lib.dontCheck (
prev.callHackageDirect {
pkg = "random";
ver = "1.3.0";
sha256 = "sha256-AzXPz8oe+9lAS60nRNFiRTEDrFDB0FPLtbvJ9PB7brM=";
} { }
);

srtree = pkgs'.haskell.lib.dontCheck (
prev.callHackageDirect {
pkg = "srtree";
ver = "2.0.1.6";
sha256 = "sha256-D561wnKoFRr/HSviacsbtF5VnJHehG73LOmWM4TxlNs=";
} { }
);

dataframe = pkgs'.haskell.lib.dontCheck (
prev.callHackageDirect {
pkg = "dataframe";
ver = "0.4.1.0";
sha256 = "sha256-u4FrhD+oOnQiGazq/TWuL0PzUvLKKAkz679tZSkiMaY=";
} { }
);

# Jailbreak packages that depend on old random
time-compat = pkgs'.haskell.lib.doJailbreak prev.time-compat;
splitmix = pkgs'.haskell.lib.doJailbreak prev.splitmix;
}
);

in
{
packages = {
default = config.packages.symbolic-regression;
symbolic-regression = haskellPackages.callCabal2nix "symbolic-regression" ./. { };
};

devShells.default = haskellPackages.shellFor {
packages = p: [ config.packages.symbolic-regression ];
buildInputs = with pkgs'; [
cabal-install
haskell-language-server
git
fourmolu
nixfmt
];
};
};
};
}
Loading