Install LinearFit in your editor
Extension RahulChaube.blyx-linearfit · 0.1.0
The extension includes a runnable Blyx example, function completions and the framework source. For the modular project, extract the starter, open its folder and run blyxc native-run main.blyx with the native toolchain installed.
Create an empty .blyx file, type blyx-linearfit-demo and accept the completion. Choose Blyx: Run File to run the example.
For an offline installation, choose Extensions: Install from VSIX for Blyx Language first, then for LinearFit.
Download the companion Blyx Language VSIXRun the command-line tool
Extract the archive for your machine and run the included CSV example. Use .\linearfit.exe in PowerShell. The input header is x,y.
./linearfit fixtures/line.csv --predict 5
The model learns slope 2 and predicts 11. Add --ridge 5 to shrink the slope to 1.
brew install rahulchaube1/blyx/linearfit
On Windows x64, add the Blyx Scoop bucket once, then install the tool from PowerShell.
scoop bucket add blyx https://github.com/Rahulchaube1/scoop-blyx scoop install blyx/linearfitScoop manifest
Install with Conda
Create an environment containing LinearFit 0.1.1, its Blyx source and a runnable example. Run the second command with Blyx 0.2.1, Rust and a host linker installed.
conda create -y --prefix ./blyx-env --override-channels -c https://rahulchaube1.github.io/blyx-packages blyx-linearfit=0.1.1=0 blyxc native-run ./blyx-env/share/blyx/linearfit/main.blyx
To use this package in your application, copy share/blyx/linearfit/vendor/linearfit from the environment into your project's vendor directory.
Import into a Blyx project
Install Blyx 0.2.1, Rust 1.85 or newer and a host linker. From the directory containing your entry file, clone this tagged release.
git clone --depth 1 --branch v0.1.1 https://github.com/Rahulchaube1/blyx-linearfit.git vendor/linearfit
Save this as main.blyx beside vendor and run blyxc native-run main.blyx.
use vendor::linearfit::linearfit;
fn main() {
let training = lf_fit([1, 2, 3, 4], [3, 5, 7, 9], 0.0);
println!(at(training, 2));
println!(lf_predict(training, 5.0));
}Expected output
2 11
API and input requirements
Provide aligned finite x and y values. At least two rows are required. Set ridge to zero for ordinary least squares, or choose a positive penalty for shrinkage. The centered model keeps predictions stable for features with large offsets.
| API | Use |
|---|---|
lf_fit(xs, ys, penalty) | Train on a pair of vectors. Returns [mean_x, mean_y, slope]. |
lf_start(), lf_update(state, x, y), lf_merge(a, b) | Accumulate rows or merge disjoint training batches. |
lf_finish(state, penalty), lf_predict(model, x) | Freeze a model and predict a response in the original units. |
lf_csv_summary(path) | Import the native csvfit module to read a CSV into a summary that lf_merge or lf_finish can use. |
Develop and contribute
Open the tagged source to read the implementation and examples. Include the smallest reproducible Blyx program, compiler version and expected result when reporting an issue.
