Skip to content
المشاريع

حول

A VisualBasic(.NET) language kernel and runtime for scientific data computing, deep learning, LLM inference, GPU acceleration, visualization and command-line data-science applications — running on .NET (net10.0) across Windows, Linux and macOS.

البيانات والتحليلات

كيف تُقاس هذه الأرقام

ما يمكنك فعله

  • Extended VisualBasic syntax — Value(Of T) inline assignment, List(Of T) with a + append operator and rich indexers, LINQ helpers (Sequence, Iterates, which, sentinel) and Unix-shell style helpers (UnixBash.ls, cat).
  • Command-line application framework — attribute-driven (<ExportAPI>, <Usage>) CLIs, automatic help generation, and InteropService to host external command-line tools.
  • VB.NET script engine (vbs) — top-level statements, ?"--arg" parameters, #include (assembly / script / NuGet), magic methods (Here(), ScriptDir()), auto-vectorized numeric array math, print data inspection in GNU R style, and make-project to promote a debugged script into a real .vbproj project.
  • Unified tabular model — NumericTable — row names + feature columns + label columns, with chainable extension methods shared across K-Means, PCA, hierarchical clustering, linear/polynomial fitting, UMAP/PaCMAP, SHAP and more.

النمو المقاس للنجوم

خلال 24 ساعة
٠
خلال 7 أيام
٠
خلال 15 يومًا
٠
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

sciBASIC#: Microsoft VisualBasic for Scientific Computing

GitHub release AppVeyor build License GPLv3 Gitter

A VisualBasic(.NET) language kernel and runtime for scientific data computing, deep learning, LLM inference, GPU acceleration (CUDA + DirectML), machine vision, physics simulation, unified data reporting and command-line data-science applications — running on .NET (net10.0) across Windows, Linux and macOS. Write your analysis as a plain vb script(.vb) or javascript(.js) script and run it directly with the built-in vbs / njs script engines, which share one standard library.


Table of Contents


Introduction

sciBASIC# is a cross-platform framework, written entirely in Microsoft VisualBasic.NET, that brings the productivity of the BASIC language to scientific computing. It bundles a large, cohesive set of reusable libraries (109 packable projects in scibasic.net.slnx) that together form the foundation for building data-science command-line tools on Windows, Linux and macOS — on modern .NET (net10.0).

The runtime is organized into cooperating layers:

Layer Source root Purpose
Core runtime Microsoft.VisualBasic.Core/ Extended VB language syntax, LINQ-style collections, a CLI application framework, the NumericTable unified data model, serialization, networking, SIMD-accelerated math and the unified data-report framework (ApplicationServices.Report).
Data framework Data/, mime/ Tabular data (DataFrame), scientific file I/O (NetCDF, HDF5, Feather, SQLite3, HDSPack), MIME / text & XML parsing (JSON, xlsx, docx, pdf, markdown, yaml), NLP (word2vec, KnowledgeGraph) and the document renderers for markdown / HTML / docx / pdf / rtf / xps.
Math & data science Data_science/ Numerical math, statistics, ODE solvers, deep learning (CNN / RNN / Transformer / GNN / LNN / SNN / ANFIS / GCN), classic ML (incl. GLMNet), dimension reduction (UMAP / PaCMAP / t-SNE), evolutionary algorithms (Darwinism), ONNX model exchange and machine vision (point clouds, U-Net, 3-D Gaussian splatting).
LLM engine llm/ A pure-managed decoder-only LLM implementation: MoE, KV cache, RoPE, function calling with constrained decoding.
GPU acceleration cuda/, Data_science/DirectML/ NVIDIA CUDA computing framework (ILCuda) and a GPU tensor runtime (ILCudaTensor), plus a DirectML backend (DXGI / D3D12 / DirectML) for Windows GPU compute and ONNX graph execution.
Graphics & visualization gr/, Data_science/Visualization The "sciBASIC# Artists" imaging engine that produces publication-quality 2D/3D plots, SVG / d3js export, network layouts and color palettes.
Physics simulation physics/ 2-D / 3-D rigid-body engine with joints, contacts and force fields; SPH fluid and boids particle simulation with a pluggable compute backend; world simulation player.
Script engines vs_solutions/VBS/, vs_solutions/NJS/, vs_solutions/libs/ vbs (VB.NET) and njs (Node-style JavaScript) hosts driven by the same stdlib / stdio API — run scripts directly without creating a project.

The design philosophy is CLI-first / script-first: instead of drag-and-drop controls, sciBASIC# emphasizes headless, scriptable, reproducible data-science programs that read files, compute, and emit figures or tables — the kind of artifacts that end up in a scientific manuscript.

3D Graphics Example From sciBASIC#


What's New

The framework has been extended substantially in the recent releases:

  1. Deep learning model zoo (Data_science/MachineLearning/) — modern neural architectures implemented in pure managed code: CNN, RNN, Transformer, ANN (in the DeepLearning package), plus dedicated packages for GNN (graph neural networks: GCN / GAT / temporal graphs), LNN (liquid neural networks with ODE-solver cells), SNN (spiking neural networks: LIF neurons, surrogate gradients, STDP), VAE, RBM, DBN and Deep-Q-Network.
  2. LLM engine (llm/) — a decoder-only language model built on the Transformer architecture: DeepSeek-style MoE routing, KV cache incremental decoding, RoPE, RMSNorm, SwiGLU, GQA/MQA, function calling with schema-constrained decoding and a full agent loop.
  3. NumericTable unified data model (Microsoft.VisualBasic.Core/src/Data/NumericTable.vb) — one table model (row names + feature columns + label columns) shared by every machine-learning algorithm in the framework, enabling chain-style data-science pipelines: NumericTableIO.ReadCsv(...).kmeans(3).pca(2).ScoreTable() …
  4. SIMD math acceleration (Microsoft.VisualBasic.Core/src/Math/SIMD/) — a substantially reworked Engine/ + Intrinsics.vb + Arithmetic/ + Parallel/ stack for hardware-vectorized arithmetic (SSE2 / AVX / ARM Advanced SIMD): element-wise math, matrix kernels and reproducible reductions, plus the Vec* vocabulary and Math.SIMD.Vectorization used by the script engine's auto-vectorizer.
  5. CUDA GPU framework (cuda/) — ILCuda (P/Invoke of the CUDA Driver API + NVRTC runtime compilation, zero third-party dependencies, and an IL → CUDA translator that compiles your .NET methods to GPU kernels) and ILCudaTensor (a double-precision GPU tensor runtime whose CudaTensor transparently switches the whole Tensor/nn operator family to the GPU).
  6. The VBS script engine (vs_solutions/VBS/) — run VB.NET scripts directly: no project, no compilation step, no deployment. The engine parses, restructures, compiles in memory via Roslyn and executes the assembly — and adds scripting-only syntax extensions (vectorized array math, let dynamic typing, tuple destructuring, @ array projection, #include of dlls/scripts/NuGet packages).
  7. The NJS JavaScript engine and shared standard library (vs_solutions/NJS/, vs_solutions/JavaScript/, vs_solutions/libs/) — njs runs .js files in a Node-like environment (REPL, process.argv, fs/path/Buffer, ANSI / plain / HTML output) and can generate TypeScript .d.ts definitions from CLR assemblies. stdio and stdlib expose the same data-science API to both vbs and njs, so a demo has one implementation and two runnable script versions.
  8. Machine-learning workflow expansion (Data_science/) — new model packages including ANFIS, GCN, GLMNet and FuzzyLogic; MLDataStorage/ONNX adds .onnx export / import plus a dependency-free forward evaluator, with a DirectML GPU session for ONNX graphs; MachineVision adds Cloudy point-cloud processing, UNet segmentation and 3-D Gaussian splatting.
  9. DirectML compute backend (Data_science/DirectML/) — beside CUDA, a zero-dependency hand-written COM vtable interop layer for DXGI / D3D12 / DirectML covering adapter discovery, command recording, descriptors, DML operator graphs and execution.
  10. Unified data reporting (Microsoft.VisualBasic.Core/src/ApplicationServices/Report/ + mime/) — one Block content model and ReportRender / IDocumentWriter interface render the same document to Markdown, HTML, plain text, docx, pdf, rtf and xps/oxps.
  11. Physics simulation (physics/) — a fixed-step 2-D / 3-D rigid-body engine (SAT contacts, joints, force fields) and a Structure-of-Arrays 3-D SPH fluid solver with boids flocking, uniform-grid neighbour search, a pluggable compute backend and force-driven label layouts.

Features

  • Extended VisualBasic syntax — Value(Of T) inline assignment, List(Of T) with a + append operator and rich indexers, LINQ helpers (Sequence, Iterates, which, sentinel) and Unix-shell style helpers (UnixBash.ls, cat).
  • Command-line application framework — attribute-driven (<ExportAPI>, <Usage>) CLIs, automatic help generation, and InteropService to host external command-line tools.
  • VB.NET script engine (vbs) — top-level statements, ?"--arg" parameters, #include (assembly / script / NuGet), magic methods (Here(), ScriptDir()), auto-vectorized numeric array math, print data inspection in GNU R style, and make-project to promote a debugged script into a real .vbproj project.
  • Unified tabular model — NumericTable — row names + feature columns + label columns, with chainable extension methods shared across K-Means, PCA, hierarchical clustering, linear/polynomial fitting, UMAP/PaCMAP, SHAP and more.
  • Deep learning — CNN (Conv2D/Pooling/Dropout/… + Softmax/SVM/Regression losses), char-level RNN, encoder–decoder Transformer with multi-head attention, feed-forward ANN, GCN/GAT graph networks, liquid time-constant networks, spiking neural networks, VAE/RBM/DBN, DQN reinforcement learning.
  • LLM inference & training — decoder-only Transformer with MoE experts, KV cache prefill + incremental decoding, RoPE positional embedding, AdamW trainer, sampling strategies and schema-constrained function calling (agent loop).
  • Classic machine learning — K-Means, hierarchical clustering, SVM, decision trees / random forest (Bonsai), Naïve Bayes, HMM, XGBoost-style gradient boosting, association rules, sequence alignment, SHAP value explanation.
  • Dimension reduction & manifold learning — PCA, UMAP, PaCMAP, t-SNE.
  • GPU heterogeneous computing — CUDA Driver API interop, NVRTC kernel compilation, device memory & streams, BLAS/reduction/element-wise kernels, IL→CUDA source translation, and a GPU tensor runtime with automatic backend switching.
  • SIMD vectorized math — System.Numerics.Vector-based element-wise arithmetic, matrix kernels (SimdMatrix), reductions (SimdReduce) and math functions (SimdMath) for float/double data.
  • Scientific file I/O — NetCDF, HDF5, Feather, SQLite3, HDSPack, msgpack and other binary formats, plus MIME text/XML and Excel (OpenXML) parsing.
  • Mathematics — linear algebra, statistics & hypothesis testing (ANOVA), data fitting / bootstrapping, Gibbs sampling, signal processing, symbolic math and ODE solvers (Runge–Kutta, SUNDIALS CVODE bindings).
  • Evolutionary algorithms — genetic algorithms and differential evolution under Microsoft.VisualBasic.MachineLearning.Darwinism.
  • Natural-language processing — word2vec, TextRank keyword extraction, KnowledgeGraph and the GraphQuery object query DSL.
  • Visualization / "Graphics Artist" — scatter, line, bar, histogram, heatmap, volcano and 3-D plots; network/force-directed layouts; SVG / d3js / PDF export; colorbrewer palettes; isometric 3-D engine; AVI video writing; Gaussian splatting 3D. Figures are tuned for printable, publication-quality output.
  • LLM proxy — bridge a local model (e.g. Ollama) or any Func(Of String, String) endpoint into the runtime via Microsoft.VisualBasic.LLMs.
  • JavaScript script engine (njs) — run .js files or start a Node-like REPL on the .NET CLR, import CLR namespaces from assemblies, and generate TypeScript .d.ts files from CLR types.
  • Shared script standard library — stdio (csv/tsv/xlsx/arff/json/MNIST IO) and stdlib (table, regression, statistics, clustering, dimension reduction, plotting, networks, reports, NLP, ML and CUDA) are identical across vbs and njs.
  • DirectML & ONNX interop — DirectML operator-graph execution on D3D12, plus .onnx export, import, inspection and CPU/GPU forward evaluation with no external inference engine.
  • Machine vision & physics simulation — point-cloud registration/reconstruction, U-Net segmentation, Gaussian splatting; rigid-body worlds, SPH fluids, boids and particle layout.
  • Unified data reporting — build documents from typed Blocks once, then render them to Markdown, HTML, plain text, docx, pdf, rtf or xps.

Installation & Build

Prerequisites

  • .NET 10 SDK (the libraries target net10.0; graphics/imaging projects additionally target net10.0-windows).
  • Visual Studio 2022 (Windows) or any editor with the VB.NET / .NET workload (Visual Studio Code + the C#/VB dev kit, or JetBrains Rider) on Linux / macOS.
  • Optional: an NVIDIA GPU + driver for the cuda/ layer, or Windows with D3D12 for Data_science/DirectML/ (everything else runs CPU-only).

Consume the packages

The individual libraries are published as NuGet packages under the Microsoft.VisualBasic.* family (e.g. the core runtime assembly Microsoft.VisualBasic.Runtime). Add them to your project with:

dotnet add package Microsoft.VisualBasic.Runtime

Build from source

Clone the repository and build the main solution, which references every library project:

git clone https://github.com/xieguigang/sciBASIC.git
cd sciBASIC
dotnet build scibasic.net.slnx -c Release

The two script hosts and their shared libraries can also be built individually:

dotnet build vs_solutions/libs/stdio/stdio.vbproj  -c Release
dotnet build vs_solutions/libs/stdlib/stdlib.vbproj -c Release
dotnet build vs_solutions/VBS/VBS.vbproj -c Release
dotnet build vs_solutions/NJS/NJS.vbproj -c Release

To build a single library, open its .vbproj (for example Microsoft.VisualBasic.Core/src/Core.vbproj, llm/llm.vbproj, Data_science/DirectML/DirectML.vbproj or physics/Engine/PhysicsEngine.vbproj), or the relevant solution under vs_solutions/, Data_science/ or physics/.


Quick Start

A. Classic sciBASIC# console application

Imports Microsoft.VisualBasic.ApplicationServices
Imports Microsoft.VisualBasic.CommandLine
Imports Microsoft.VisualBasic.CommandLine.Reflection

Module Program

    Public Function Main() As Integer
        ' Standard sciBASIC# CLI entry point: dispatches /switch based on
        ' <ExportAPI> methods and auto-generates the help screen.
        Return GetType(Program).RunCLI(App.CommandLine)
    End Function

    <ExportAPI("/hello")>
    <Usage("/hello /name <string>")>
    Public Function Hello(args As CommandLine) As Integer
        Call Console.WriteLine($"Hello, {args("/name")}!")
        Return 0
    End Function

End Module
yourapp.exe /hello /name "sciBASIC#"
# -> Hello, sciBASIC#!

B. Or just write a script — no project needed

Save hello.vb:

' No Module, no Sub Main — top-level statements just work.
Dim name As String = ?"--name"      ' read a command-line argument

Call Console.WriteLine($"Hello, {name}!")

Dim x = {1, 2, 3, 4, 5}
Call print(x * 2 + 1)               ' vectorized array math, R-style output
' [1]  3  5  7  9 11

Run it with the vbs host (see The VBS Script Engine):

dotnet build vs_solutions/VBS/VBS.vbproj -c Release
.nuget/net10.0/vbs.exe hello.vb --name "sciBASIC#"

C. Or write JavaScript — same library, another host

Save hello.js:

import stdio from '../../.nuget/net10.0/stdio.dll';
import stdlib from '../../.nuget/net10.0/stdlib.dll';

const table = stdio.read.csv('iris.csv', ['D1', 'D2', 'D3', 'D4']);
const model = stdlib.fit.linear(table, 'y');

console.log(`R2 = ${model.r2}, RMSE = ${model.rmse}`);

Run it with njs, or just type njs for the interactive REPL:

dotnet build vs_solutions/NJS/NJS.vbproj -c Release
.nuget/net10.0/njs.exe hello.js

See Shared Script Libraries for the full API surface.


NumericTable — One Data Model for the Whole Data-Science Pipeline

Microsoft.VisualBasic.Core/src/Data/NumericTable.vb defines the framework's unified 2-D data model: row names + feature columns + label columns (labels are the label:-prefixed columns). Every machine-learning algorithm in sciBASIC# understands this model, so data flows between algorithms without conversion glue code — you simply chain the steps.

Imports Microsoft.VisualBasic.Data

' 1. Load a csv (row names + D1..D4 feature columns; text class column ignored)
Dim table = NumericTableIO.ReadCsv("bezdekIris.csv", columns := {"D1","D2","D3","D4"})

' 2. K-Means clustering writes its result back into the table's label matrix
Dim result = table.kmeans(k := 3)

' 3. PCA on the clustered table -> project to the first two components
Dim score = result.pca(maxPC := 2).ScoreTable()

' 4. Pull columns for plotting
Dim pc1 = score.Feature("PC1")
Dim pc2 = score.Feature("PC2")

(excerpt from tutorials/VBS/scripts/kmeans/kmeans.vb — a complete Iris clustering + PCA + scatter-plot demo)

Regression works the same way:

Dim model = table.LinearFit(y := "y")          ' linear regression on the label column
Dim quad  = table.PolyFit(poly_n := 2)         ' polynomial comparison model
Dim out   = table.SetPrediction(model, withResidual := True)   ' new table + prediction/residual labels

Call out.WriteCsv("fit.csv")

(excerpt from tutorials/VBS/scripts/linear_regression/linear_regression.vb)

Key API surface: nsamples / nfeatures / nlabels, Feature(name), GetLabel(name), SetLabel(name, values), Slice(rows), Select(cols), Clone(), plus IO helpers (NumericTableIO.ReadCsv, WriteCsv) and R-style print(tbl) table rendering.


Deep Learning Suite

All models are implemented in pure managed VB.NET on a shared tensor runtime — no PyTorch/TensorFlow native runtime required, while the GPU can be layered on through ILCudaTensor.

Package (Data_science/MachineLearning/…) Models Highlights
DeepLearning (DeepLearning.NET6.vbproj) CNN (CNN: Conv2D, Conv2DTranspose, Pooling, Dropout, Maxout, LRN, Fourier-feature, Gaussian layers; Softmax/SVM/Regression loss layers; model save/load), RNN (char-level), Transformer (encoder/decoder stacks, multi-head attention), ANN (NeuralNetwork) SGD / AdaGrad / Adam optimizers, trainer loops, CeNiN model import
GNN (GNN.vbproj) GCN layer, Graph attention (GAT), GRU/RNN recurrent graph layers, temporal graph models, graph classification message-passing on graphs, dynamic-graph snapshots
LNN (LNN.vbproj) Liquid neural networks — LiquidCell/LiquidLayer, ODE-solver based continuous-time units time-series utilities, liquid trainer
SNN (SNN.vbproj) Spiking neural networks — LIF / recurrent-LIF / sparse-LIF layers, rate & temporal encoders/decoders, surrogate gradients, STDP learning third-generation neural networks with spike trains
VAE / RestrictedBoltzmannMachine / DBNCode Variational autoencoder, RBM, deep belief networks unsupervised representation learning
DeepQNetwork (DeepQNetwork.vbproj) DQN reinforcement learning Q-learning on neural function approximators
xgboost / XGBoostDataSet gradient-boosted trees tabular learning with the NumericTable dataset format
ML_SHAP SHAP value explanation model-agnostic feature attribution
MLDataStorage / MachineLearning.Data.Extensions ML data packing & NumericTable bridges interop glue between packages

Minimal CNN example:

Imports Microsoft.VisualBasic.MachineLearning
Imports Microsoft.VisualBasic.MachineLearning.CNN
Imports Microsoft.VisualBasic.MachineLearning.CNN.trainers

Dim net As New ConvolutionalNetwork()
Call net.AddLayer(New ConvolutionLayer(filters:=32, kernelSize:=3))
Call net.AddLayer(New PoolingLayer(size:=2))
Call net.AddLayer(New DenseLayer(units:=10))
Call net.Compile(loss:=New SoftmaxCrossEntropy())

Dim trainer As New SGDTrainer(optimizer:=Optimizer.Adam, learningRate:=0.001)

For epoch As Integer = 1 To 20
    Call trainer.TrainEpoch(net, trainData)
Next

LLM Engine (Decoder-Only Transformer)

llm/llm.vbproj provides a pure-managed decoder-only language model covering three main lines beside the classic encoder–decoder Transformer in DeepLearning:

Line Types What it does
Mixture of Experts MoELayer DeepSeekMoE: fine-grained expert splitting + shared expert isolation + Sigmoid Top-K routing + auxiliary-loss-free load balancing + node-limited routing
KV Cache KVCache, CausalSelfAttention prefill + incremental decoding — per-step attention cost drops from O(t²) to O(t); nKvHeads < nHeads gives GQA/MQA
Function calling ToolCallProtocol, JsonSchema, ConstrainedDecoder, ToolRegistry, AgentLoop tool schema injection → constrained decoding (schema compiled to a finite-state machine, illegal tokens masked to -inf) → parse → execute → feed back → multi-turn loop

Supporting modules: RmsNorm, RotaryEmbedding (RoPE), SwiGLUFeedForward, LLMBlock, LLMModel, Sampler, LMTrainer (AdamW, warmup + cosine schedule, gradient clipping), ParameterSet, TokenStream, TokenizerVocabulary. No automatic differentiation framework — backprop is hand-written per component against cached forward snapshots, keeping the whole engine readable and debuggable.

' Build & train (see TalkBuddy/test/Program.vb for the full walkthrough:
' pretraining -> instruction SFT -> tool-call SFT -> MoE routing stats
' -> sampling comparison -> KV-cache consistency -> multi-turn tool calling)
Dim model As New LLMModel(New LLMModelConfig With {.dModel = 512, .nLayers = 8, ...})
Dim trainer As New LMTrainer(model, New AdamW(model.Parameters, lr:=0.0003))
Call trainer.TrainStep(batch)

GPU Acceleration — ILCuda & ILCudaTensor

The cuda/ root brings native NVIDIA GPU heterogeneous computing to sciBASIC# — with zero third-party NuGet dependencies (it P/Invokes nvcuda.dll and nvrtc64_*.dll directly).

Project Role
cuda/ILCuda/ILCuda.vbproj CUDA compute framework: device/context/stream management, device memory & pinned host buffers, NVRTC multi-pass kernel compilation, kernel registry & launch planning, built-in reduction / element-wise / BLAS (GEMM, GEMV) kernels, structured diagnostics. Includes IL2Cuda: an IL → AST → CUDA-C translator with <CudaKernel>/<CudaInput>/<CudaOutput> attributes that turns ordinary .NET methods into GPU kernels.
cuda/ILCudaTensor/ILCudaTensor.vbproj GPU tensor runtime: device-resident CudaTensor (dense + CSR sparse storage) and a set of double-precision kernels (GEMM, softmax, reductions, conv/pool, sparse×dense). One Register() call switches the whole TensorFlow-style Tensor/Math/nn operator family to the GPU backend — operators without a GPU kernel silently fall back to the CPU implementation, so nothing ever breaks.
' After one registration, tensor math runs on the GPU automatically:
Call CudaTensor.Register()

Dim a = Tensor.Random(2048, 2048)
Dim b = Tensor.Random(2048, 2048)
Dim c = a * b      ' GEMM on the GPU, double precision

The ILCuda test project doubles as a demo CLI:

dotnet ILCuda.Demo.dll info        # device & NVRTC environment probe (with memory info)
dotnet ILCuda.Demo.dll demo        # pearson-correlation + euclidean-distance matrices on GPU
dotnet ILCuda.Demo.dll selftest    # kernel-logic self-check (no GPU required)

DirectML Compute & ONNX Interop

Data_science/DirectML/DirectML.vbproj adds a second heterogeneous-computing path beside CUDA: a zero-dependency, hand-written COM vtable interop layer for DXGI, D3D12 and DirectML. It covers adapter / device enumeration, command recording, buffer and descriptor management, DML operator descriptors, graph compilation and execution, and a native ONNX graph backend.

Data_science/MachineLearning/MLDataStorage/ONNX/ makes the framework interoperable with the wider ML ecosystem without pulling in an inference engine:

  • cnn.SaveOnnx(path) exports a trained CNN (float32 by default, float64 for lossless round-trips);
  • OnnxImport.Load(path) restores a ConvolutionalNN that can be trained further;
  • OnnxModel.Load(path).Summary() inspects metadata, operator sequence and tensor shapes;
  • OnnxGraphEvaluator(model).RunSingle(observation) performs CPU forward inference with no engine;
  • DmlOnnxSession.Create(model, options) compiles the same graph to DirectML operators and runs it on the GPU through Data_science/DirectML/.
Imports Microsoft.VisualBasic.MachineLearning.DataStorage.ONNX
Imports Microsoft.VisualBasic.MachineLearning.DataStorage.ONNX.DirectML

Dim model = OnnxModel.Load("./model.onnx")
Call Console.WriteLine(model.Summary())

Dim y = New OnnxGraphEvaluator(model).RunSingle(observation)   ' CPU

Using session = DmlOnnxSession.Create(model, New DmlOnnxOptions With {.AllowCpuFallback = False})
    Call Console.WriteLine(session.Summary())                  ' adapter, feature level, operators, VRAM
    Dim yGpu = session.RunSingle(observation)                  ' same API shape, GPU
End Using

Dim unsupported = DmlOnnxCapabilities.FindUnsupported(model)   ' preflight a model

Unsupported operators are reported explicitly (OnnxUnsupportedOperatorException / OnnxDmlUnsupportedOperatorException) rather than silently degraded; set AllowCpuFallback = True to opt into a CPU fallback, and session.Backend reports which backend actually ran. The protobuf codec is the in-repo Microsoft.VisualBasic.Data.IO.Protobuf package, so no extra NuGet dependency is introduced.


SIMD Math Acceleration

Microsoft.VisualBasic.Core/src/Math/SIMD/ is the CPU-side high-performance math core, used by the machine-learning packages and by the script engine's auto-vectorizer:

SIMD/
├── SimdEngine.vb          # capability detection & dispatch (SSE2 / AVX / ARM Advanced SIMD)
├── SimdMath.vb            # vectorized math functions (sqrt, exp, log, abs, ...)
├── SimdMatrix.vb          # matrix kernels
├── SimdReduce.vb          # sum / min / max / mean reductions (sequential, reproducible floats)
├── SimdCompare.vb / SimdCapabilities.vb
├── SimdExtensions.vb      # Simd* extension vocabulary
├── Vectorized.vb          # the Vec* operator vocabulary (VecAdd / VecMultiply / VecSum / ...)
├── Arithmetic/            # Add / Subtract / Multiply / Divide / Modulo / Exponent facades
└── Parallel/              # block-parallel variants

Script authors rarely call these directly — when a script performs arithmetic on numeric arrays, the VBS engine rewrites the expression tree into Vec* calls (see below), which resolve to these SIMD kernels at runtime.


The VBS Script Engine

vs_solutions/VBS/VBS.vbproj builds the vbs scripting host: run a .vb file directly, without creating a VS project or compiling an exe. The engine textually parses and restructures the script, compiles it in memory through Roslyn, executes it via reflection inside a collectible AssemblyLoadContext (fully unloaded afterwards), and never touches disk.

vbs ./run.vb --a=123 --flag          # run a script with arguments
vbs ./run.vb --verbose               # print the generated compilable code + debug build
vbs ./run.vb --no-vectorize          # disable auto-vectorization
vbs make-project ./run.vb            # promote the script into a real vbproj project

Scripting syntax extensions

Feature Example
Top-level statements & functions no Module/Sub Main boilerplate; top-level functions become local lambdas automatically
Command-line arguments Dim a As Integer = ?"--a" → rewritten to args("--a") with automatic type conversion
#include reference a dll (#include "Microsoft.VisualBasic.Drawing.dll"), another script (#include "./lib/Helper.vb"), or a NuGet package (#include "[email protected]", with transitive dependency resolution and the local ~/.nuget/packages cache)
Magic methods ScriptDir(), ScriptFile(), Here(relpath), Includes(), Locate(name), Package()/Author()/Version() …
Dynamic typing let b = 456 → Object variable, re-bindable at runtime (b = New With {.a = 123} … b.a)
Tuple destructuring Dim (a, b) = (1, 2), For Each (str, int) In tuples, nested & named forms
Vectorized array math Dim z = (x * y + 6) / (x + y) on numeric arrays → auto-expanded to SIMD Vec* calls
@ array projection list@x → list.Select(Function(o) o.x).ToArray() (Perl style, chainable, vectorizable)
Default parameter expressions Optional c = If(b, New testdata(a), New testdata("default")) — arbitrary expressions as defaults
print GNU R-style vector/table/NumericTable printing with wrapping, NA/NULL handling and width/digits options

A complete data-science script

tutorials/VBS/scripts/kmeans/kmeans.vb — Iris clustering + PCA + chart export, runnable as-is:

#include "Microsoft.VisualBasic.DataMining.Framework.dll"
#include "Microsoft.VisualBasic.Data.Framework.dll"
#include "Microsoft.VisualBasic.Data.DataPlot.dll"
#include "Microsoft.VisualBasic.Math.Statistics.ANOVA.dll"
#include "Microsoft.VisualBasic.Drawing.dll"

imports microsoft.visualbasic.data
imports microsoft.visualbasic.datamining.kmeans
imports microsoft.visualbasic.data.plots
imports microsoft.visualbasic.drawing

dim file = here("../../data/bezdekIris.csv")      ' magic method: relative to the script
dim k = 3

dim table = NumericTableIO.ReadCsv(file, columns := {"D1","D2","D3","D4"})
dim result = table.kmeans(k := k)                  ' clustering via the unified table model
dim score = result.pca(maxPC := 2).ScoreTable()    ' PCA projection

dim pc1 = score.Feature("PC1")
dim pc2 = score.Feature("PC2")
' ... build a ScatterPlot and save a PNG next to the script ...

Run it:

cd .nuget/net10.0
vbs.exe G:\GCModeller\src\runtime\sciBASIC#\tutorials\VBS\scripts\kmeans\kmeans.vb

The tutorials/VBS/scripts/ folder contains many more runnable demos, most with expected output (stdout.txt) and generated figures: linear_regression, word2vec (word vectors + UMAP + K-Means), hola_layout (orthogonal network layout), mnist_cnn, spiking_nn, tf-idf, hierarchical_clustering, mnist_umap, dynamic_type, tuple.

VBS.vbproj can also be embedded as a class library:

Imports VBScriptHost.Script

Dim vbs As ScriptParseResult = VBScript.ParseScript("./run.vb")

Using runtime As ScriptRuntime = vbs.CompileScript()
    Dim exitCode As Integer = runtime.Run({"--a", "123"})
End Using   ' the dynamic assembly is unloaded here

The NJS JavaScript Script Engine

vs_solutions/NJS/NJS.vbproj builds njs, a Node-like host for the pure-managed LiteJs JavaScript engine (vs_solutions/JavaScript/LiteJs.vbproj). It shares the CLR bridge and the script libraries with vbs, so the same data-science API is available from JavaScript.

njs ./run.js                       # run a script (process.argv, __dirname, __filename, fs / path / Buffer)
njs                                # interactive REPL: persistent globals, trailing expression echoed
njs ./run.js --plain               # buffered plain output for byte-level comparison
njs ./run.js --html report.html    # styled standalone HTML output
njs --dts stdlib.dll -o stdlib.d.ts --xmldoc stdlib.xml   # generate TypeScript declarations
  • --ansi (default) renders %c CSS styles through ConsoleIO as ANSI escape sequences; --plain and --html <file> select LogTextIO and HtmlIO.
  • import stdlib from '../../.nuget/net10.0/stdlib.dll' is the CLR namespace import: the alias receives the public types of that namespace (stdlib.fit.linear(...), stdio.read.csv(...)).
  • --dts reflects the same rules the runtime bridge uses, so editor completion matches runtime behaviour. Dependency trees of imported assemblies are resolved automatically (managed assemblies by simple name, native ones through runtimes/*/native).

Shared Script Libraries

vs_solutions/libs/ contains the common standard library used by both hosts. Scripts written against it run unchanged under vbs and njs; only the import syntax differs.

Library API modules
stdio (stdio.vbproj) read / write: csv, tsv, table, xlsx, arff, json, text, lines, mnist
stdlib (stdlib.vbproj) table, fit, stats, lapack, cluster, dimreduce, plot, net, report, nlp, ml, cuda
' VBS
#include "stdlib.dll"
#include "stdio.dll"
imports stdlib
imports stdio

dim table = read.csv("iris.csv", columns:={"D1", "D2", "D3", "D4"})
dim model = fit.linear(table, "y")
call write.csv(table, here("result.csv"))
// NJS
import stdlib from '../../.nuget/net10.0/stdlib.dll';
import stdio from '../../.nuget/net10.0/stdio.dll';

const table = stdio.read.csv('iris.csv', ['D1', 'D2', 'D3', 'D4']);
const model = stdlib.fit.linear(table, 'y');
console.log(`R2 = ${model.r2}, RMSE = ${model.rmse}`);

All table readers/writers use NumericTable (row names + feature columns + label: columns). The bridge deliberately accepts arrays, primitives, NumericTable and library-owned model types — not generics, delegates or IEnumerable(Of T) — which keeps the same API callable from both engines. See vs_solutions/libs/readme.md for the complete reference; tutorials/VBS/scripts/<demo>/ ships a .vb and a .js version of each demo with identical output.


Unified Data Reporting

Microsoft.VisualBasic.Core/src/ApplicationServices/Report/ defines a single content model and a common output contract:

  • Block — heading, paragraph, code, list, blockquote, table, image, math, footnote, …;
  • ReportRender — renders IEnumerable(Of Block) into a target format;
  • IDocumentWriter — the fluent docx / pdf writing interface (title, styles, TOC, tables, images);
  • ToMarkdown / ToHtml / ToPlainText extension methods for the text renderers.

Renderers live in Core (TextRender, HtmlRender, PlainTextRender) and in mime/ (WordRender → docx, PdfRender → pdf, RtfRender → rtf, XpsRender → xps/oxps). One document therefore produces every format:

' Through the shared library (works in vbs and njs)
dim doc = report.document("Linear regression report", "sciBASIC", toc:=False)
call doc.add(report.heading("1. Dataset"))
call doc.add(report.paragraph("100 samples of one feature column."))
call doc.add(report.tableOf(dataset))
call doc.add(report.image(here("figure.png"), "scatter"))

call doc.save(here("report.md"))     ' .md / .html / .txt
call doc.save(here("report.docx"))   ' .docx / .pdf / .rtf / .xps / .oxps

Binary formats embed images from real files on disk, so draw the figure first (plot.save) and pass its path to report.image.


Machine Vision & Physics Simulation

Machine vision (Data_science/MachineVision/):

  • Cloudy — a managed 3-D point-cloud pipeline: SoA buffers, spatial neighbourhoods, voxel / statistical / radius outlier filters, ISS + FPFH features, RANSAC / ICP / NDT / PCS4 registration, pose-graph optimization, Poisson and TSDF reconstruction, segmentation, plus 6-DoF pose estimation, hand-eye calibration, grasp planning, CAD deviation analysis and geometric tolerances.
  • UNet — symmetric encoder–decoder semantic segmentation on the sciBASIC# CNN layers, with mini-batch Adam/SGD training, DSB2018 dataset loading, RLE masks and IoU/Dice metrics.
  • GaussianSplatting3D — 3-D Gaussian splatting rendering.

Physics (physics/):

  • Engine/PhysicsEngine.vbproj — fixed-step 2-D / 3-D rigid-body worlds: broad/narrow phase collision, SAT convex-polyhedron contacts, revolute / prismatic / spring / weld / ball / hinge joints, angular motors, gravity / wind / magnetic force fields and SPH/boids hooks.
  • Particles/Particles.vbproj — Structure-of-Arrays 3-D SPH fluid solver (box, cylinder and rotating impeller boundaries, uniform-grid neighbour search, pluggable CPU/CUDA backend), 3-D boids flocking, a pooled 2-D particle system with emitters and force-driven label layouts.
  • WorldPlayer/ — the world-simulation player.

Module & Namespace Overview

The framework exposes a large, consistent set of namespaces. The tables below group them by layer (each row corresponds to a library project in scibasic.net.slnx). Names marked with * ship from the data-science runtime (the Data/, Data_science/, gr/, cuda/, llm/, nlp/ and mime/ roots) rather than the general core.

Core runtime — Microsoft.VisualBasic.Core (Core.vbproj)

Namespace Description
Microsoft.VisualBasic.Language Extended VB syntax: Value(Of T), List(Of T), Vector, UnixBash shell helpers.
Microsoft.VisualBasic.Language.Linq LINQ-style collection helpers (Sequence, Iterates, which, sentinel).
Microsoft.VisualBasic.CommandLine CLI application framework, InteropService, POSIX helpers.
Microsoft.VisualBasic.ApplicationServices App host, logging, println, debug port (8081).
Microsoft.VisualBasic.ApplicationServices.Report Unified data reporting: Block content model, ReportRender, IDocumentWriter, ToMarkdown / ToHtml / ToPlainText.
Microsoft.VisualBasic.Data NumericTable — the unified data model for machine learning + NumericTableIO.
Microsoft.VisualBasic.Math.SIMD SIMD math acceleration: SimdEngine/SimdMath/SimdMatrix/SimdReduce + the Vec* operator vocabulary.
Microsoft.VisualBasic.ComponentModel Component model: Collection, DataSourceModel, Range, settings.
Microsoft.VisualBasic.Scripting Symbol tables and dynamic math-expression evaluation.
Microsoft.VisualBasic.Serialization JSON / XML (de)serialization.
Microsoft.VisualBasic.Net HTTP / networking utilities.
Microsoft.VisualBasic.Text StringBuilder helpers and CSV/text utilities.
Microsoft.VisualBasic.Drawing Color and 2-D drawing primitives.
Microsoft.VisualBasic.LLMs LLM proxy: HookOllama, LLMsTalk.
Microsoft.VisualBasic.Printing GNU R-style data printing (print, ToText).

Data framework — Data/ & mime/ **

Namespace Description
Microsoft.VisualBasic.Data.Framework * (dataframework) In-memory DataFrame, CSV / TSV I/O and reflection-based EntityObject storage.
Microsoft.VisualBasic.Data.Framework.Extensions * DataFrame extension utilities.
Microsoft.VisualBasic.Data.BinaryData * (binarydata) Binary scientific formats, including NetCDF.
Microsoft.VisualBasic.Data.HDF5 / Feather / SQLite3 / HDSPack / msgpack / DataStorage * Scientific storage: HDF5, Feather, embedded SQLite3, packed binary datasets, msgpack.
Microsoft.VisualBasic.Data.Trinity * In-memory triple-store / key-value storage.
Microsoft.VisualBasic.Data.MyersDiff * Myers diff algorithm.
Microsoft.VisualBasic.Data.GraphQuery * GraphQuery object query DSL and engine.
Microsoft.VisualBasic.MIME.Markup * JSON / HTML / XML / Markdown text parsing.
Microsoft.VisualBasic.MIME.Office.Excel * (xlsx) Excel (OpenXML / .xlsx) reading & writing.
mime/text%yaml, text%html, application%pdf, application%rdf+xml, application%rtf, ...wordprocessingml.document * YAML, HTML, PDF, RDF/XML, RTF and DOCX parsers/writers.

Math & data science — Data_science/ **

Namespace Description
Microsoft.VisualBasic.Math * (Math) Core numerical math (root namespace of the Mathematica library).
Microsoft.VisualBasic.Math.LinearAlgebra * Vectors, matrices, matrix decomposition.
Microsoft.VisualBasic.Math.Statistics * (ANOVA, stats) Descriptive statistics, distributions, hypothesis tests (ANOVA).
Microsoft.VisualBasic.Math.Calculus.Dynamics * (ODE) ODE system solver (ODEs, Runge–Kutta).
Microsoft.VisualBasic.Math.Sundials.CVODE * SUNDIALS CVODE stiff/non-stiff ODE bindings.
Microsoft.VisualBasic.Math.DataFrame * Math-side dataframe utilities.
Microsoft.VisualBasic.Math.SignalProcessing * Signal processing (+ Signal.IO, wav).
Microsoft.VisualBasic.Math.GibbsSampling * Gibbs sampling.
Microsoft.VisualBasic.Math.Symbolic.GeneticProgramming * / MathLambda * Symbolic / genetic programming math, lambda symbolic engine.
Microsoft.VisualBasic.Math.Randomizer * Random number helpers.
Microsoft.VisualBasic.Math.mHG / KaplanMeierEstimator * mHG statistics, Kaplan–Meier estimator.
Microsoft.VisualBasic.DataMining * Data mining: clustering, Association Rules, sequence alignment, NumericTable integration.
Microsoft.VisualBasic.DataMining.BinaryTree / Bonsai / HMM / DynamicProgramming / DensityQuery / FeatureFrame * Decision trees, random forest, HMM, DP algorithms, density queries, feature frames.
Microsoft.VisualBasic.DataMining.UMAP / PaCMAP / t-SNE / hierarchical-clustering * Dimension reduction & manifold learning (all consume NumericTable).
Microsoft.VisualBasic.MachineLearning * (machine_learning) Machine learning: SVM, decision tree, Naïve Bayes, PCA, NumericTable extensions (kmeans, LinearFit, PolyFit, SetPrediction...).
Microsoft.VisualBasic.MachineLearning.Darwinism * Evolutionary algorithms (genetic algorithm, differential evolution).
Microsoft.VisualBasic.MachineLearning.Convolutional / RNN / Transformer / NeuralNetwork * (DeepLearning) Deep learning: CNN, char-level RNN, encoder–decoder Transformer, feed-forward ANN.
Microsoft.VisualBasic.DeepLearning.GNN * Graph neural networks: GCN, GAT, temporal graphs, graph classification.
Microsoft.VisualBasic.DeepLearning.LNN * Liquid neural networks (ODE-solver cells, time-series).
Microsoft.VisualBasic.DeepLearning.SNN * Spiking neural networks (LIF, STDP, surrogate gradients).
Microsoft.VisualBasic.MachineLearning.VAE / RestrictedBoltzmannMachine / DBNCode * VAE / RBM / deep belief networks.
Microsoft.VisualBasic.MachineLearning.DeepQNetwork * DQN reinforcement learning.
Microsoft.VisualBasic.MachineLearning.xgboost * / XGBoostDataSet Gradient-boosted trees + dataset format.
Microsoft.VisualBasic.MachineLearning.ML_SHAP * SHAP feature attribution.
Microsoft.VisualBasic.DeepLearning.ANFIS * Adaptive Network-based Fuzzy Inference System (hybrid least-squares / backprop TSK training).
Microsoft.VisualBasic.DeepLearning.GCN * Graph convolutional networks (dense / CSR normalized adjacency, AdamW, early stopping).
Microsoft.VisualBasic.MachineLearning.GLMNet * Lasso / elastic-net regularized GLMs (gaussian, logistic, multinomial, Poisson, Cox).
Microsoft.VisualBasic.MachineLearning.DataStorage.ONNX * (MLDataStorage) ONNX export / import, model inspection and dependency-free graph evaluation; ONNX.DirectML adds GPU sessions.
Microsoft.VisualBasic.MachineLearning.CellularAutomaton * Cellular automata (Game of Life).
Microsoft.VisualBasic.MachineVision.Cloudy * 3-D point clouds: filtering, features, ICP/NDT registration, Poisson/TSDF reconstruction, segmentation and industrial inspection.
Microsoft.VisualBasic.MachineVision.UNet * U-Net semantic segmentation with DSB2018 data, RLE masks and IoU/Dice metrics.
Microsoft.VisualBasic.Math.MachineVision * / GaussianSplatting3D Machine vision; 3D Gaussian splatting.
Data_science/Graph * Graph algorithms (PageRank etc.).

LLM & GPU accelerators **

Namespace Description
llm/llm.vbproj * Decoder-only LLM engine: LLMModel, MoELayer, KVCache, CausalSelfAttention, RotaryEmbedding, RmsNorm, SwiGLUFeedForward, ConstrainedDecoder, AgentLoop, LMTrainer, AdamW, Sampler.
Microsoft.VisualBasic.Computing.ILCuda.* * (ILCuda) CUDA framework: driver interop, NVRTC compilation, device memory/streams, BLAS & reduction kernels, IL2Cuda IL→CUDA translator.
Microsoft.VisualBasic.Computing.ILCuda.GPUTensor * (ILCudaTensor) GPU tensor runtime: CudaTensor, dense/CSR storage, GEMM/softmax/conv/pool kernels, transparent CPU fallback.
Microsoft.VisualBasic.Computing.DirectML * (DirectML) DirectML compute: DXGI / D3D12 / DML COM interop, operator descriptors and graph compilation/execution; hosts the ONNX GPU backend.
Microsoft.VisualBasic.Computing.JSCuda * (JsCuda) JavaScript → CUDA translation: decompiles a script function into a typed AST and emits a CUDA kernel through ILCuda.

Visualization & graphics — Data_science/Visualization & gr/ **

Namespace Description
Microsoft.VisualBasic.Data.ChartPlots * (plots) Plotting: scatter, line, bar, histogram, heatmap, volcano, 3-D.
Microsoft.VisualBasic.Data.Plots * (DataPlot) Plot abstraction + NumericTable-driven plotting.
Microsoft.VisualBasic.Imaging * "Graphics Artist" device: GraphicsData, drawing primitives.
Microsoft.VisualBasic.Imaging.Drawing2D * 2-D vector graphics, colors, styles.
Microsoft.VisualBasic.Data.visualize.Network * Force-directed network layout & rendering.
Microsoft.VisualBasic.Data.visualize.Network.Layouts * (network_layout) Layout algorithms incl. HOLA orthogonal layout.
Microsoft.VisualBasic.Data.visualize.Network.IO * / NetworkCanvas / Visualizer Network I/O extensions, interactive canvas, visualizer.
Microsoft.VisualBasic.Imaging.colorbrewer * Publication color palettes.
gr/physics * Physics simulation helpers.
gr/Landscape * Procedural landscape rendering.
gr/avi * AVI video writing.
Microsoft.VisualBasic.Drawing (DXApi, DxCanvas, TrueType) GDI+/Skia drawing devices, TrueType fonts.
gr/Drawing-net4.8 Classic .NET Framework drawing backend.

NLP — nlp/ **

Namespace Description
Microsoft.VisualBasic.Data.NLP.Word2Vec * word2vec training (CBOW / Skip-gram).
Microsoft.VisualBasic.Data.NLP * NLP model types, segmentation.
Microsoft.VisualBasic.Data.NLP.TextRank * TextRank keyword extraction.
nlp/KnowledgeGraph * Knowledge graph construction.

Physics simulation — physics/ **

Namespace Description
Microsoft.VisualBasic.Engine.Physics * (PhysicsEngine) 2-D / 3-D rigid bodies, broad & narrow phase collision, SAT convex contacts, joints, angular motors, gravity / wind / magnetic fields.
Microsoft.VisualBasic.Engine.Particles * (Particles) SoA 3-D SPH fluid solver, uniform-grid neighbour search, boids flocking, pooled 2-D particle system, force-driven label layout; pluggable compute backend.
physics/WorldPlayer World simulation player.

Scripting & tooling

Project Description
vs_solutions/VBS/VBS.vbproj The vbs script engine (see above).
vs_solutions/NJS/NJS.vbproj The njs JavaScript host (LiteJs): scripts, REPL, TypeScript .d.ts generation (see above).
vs_solutions/libs/stdio, vs_solutions/libs/stdlib Shared script standard library for both vbs and njs (see above).
vs_solutions/dev/VisualStudio VB project tooling + the VBProj.NuGet client used by #include NuGet resolution.
vs_solutions/dev/vs_PDB PDB utilities.
vs_solutions/PkgVersionUpgrade Package version migration tool.
www/axel, www/Microsoft.VisualBasic.Webservices.Bing HTTP client utilities, web services.
docs/guides, tutorials/ Language guides (LanguageSyntax, VectorDemo, parameter_expression) and demos (MESH, ModelViewer, logo).

Extended VisualBasic Language

sciBASIC# extends the VB.NET surface so that small data-science scripts read almost like a domain-specific language. All of the helpers below live in Microsoft.VisualBasic.Language (core runtime) unless noted.

Inline value assignment — Value(Of T)

Imports Microsoft.VisualBasic.Language

Dim line As Value(Of String) = ""

' inline assignment
Do While (line = stream.ReadLine) IsNot Nothing
    ' ...
Loop

List(Of T) append operator and rich indexers

The core List(Of T) overloads +, so l += item appends, and it exposes Python-like slice/negative indexers:

Imports Microsoft.VisualBasic.Language

Dim l As New List(Of String)
l += "a"
l += "b"
l += "c"

Dim last = l(-1)          ' "c"
Dim slice = l(0, 2)       ' { "a", "b" }

LINQ-style sequence helpers

Imports Microsoft.VisualBasic.Language
Imports Microsoft.VisualBasic.Linq

' 100.Sequence -> 0 .. 99
Dim squares = 100.Sequence _
    .Select(Function(i) i * i) _
    .ToArray

For Each x In New List(Of Integer)({1, 2, 3}).IteratesALL
    Call Console.WriteLine(x)
Next

Unix-shell style helpers — UnixBash

Imports Microsoft.VisualBasic.Language

' list files, recursively, long format — mirroring the `ls -l -r` shell command
Dim files = (ls - l - r)  _
    .Select(Function(path) path.FullName) _
    .ToArray

Dim text = cat("data/notes.txt")   ' read a whole file as one string

println and the application host

Imports Microsoft.VisualBasic.App

Call println("hello from sciBASIC#")

Vectorized array math (scripts & runtime)

Numeric vectors participate in arithmetic directly; the runtime dispatches to the SIMD kernels:

Dim x = {1, 2, 3, 4, 5}
Dim y = {2, 3, 4, 5, 1}

Dim sum = x + 5                  ' => VecAddScalar(Of Integer)(x, 5)
Dim z = (x * y + 6) / (x + y)    ' whole expression tree expanded element-wise

Call print(x.Average())          ' [1] 3

Inside a vbs script this rewriting is automatic; in a compiled project the same operators are available through the Microsoft.VisualBasic.Math.SIMD.Vectorization vocabulary.


Examples by Domain

Tabular data & file I/O (Data/)

Imports Microsoft.VisualBasic.Data.Framework.IO
Imports Microsoft.VisualBasic.Data.Framework.StorageProvider

' Load a CSV into an in-memory dataframe resolver:
Dim df = DataFrameResolver.Load("data.csv")

' Strongly-typed loading into entity objects (confirmed API):
Dim people = EntityObject.LoadDataSet(Of Person)("people.csv")

Reading a NetCDF scientific file:

Imports Microsoft.VisualBasic.Data.BinaryData

Dim nc = netCDFReader.Open("model.nc")
Dim v = nc.getDataVariable("temperature")   ' ICDFDataVector
Dim data = v.genericValue                   ' System.Array of the variable

The chain-style data-science pipeline (NumericTable)

See NumericTable above — load → cluster → reduce → plot → export in a single fluent chain, shared by every ML package.

Deep learning training (Data_science/MachineLearning/)

See Deep Learning Suite for the CNN snippet; GNN, LNN and SNN follow the same add-layer → compile → train pattern (SGD/Adam), each with its own focused package.

LLM inference (llm/)

See LLM Engine — MoE routing, KV-cache decoding and schema-constrained function calling with a complete agent loop.

GPU kernels (cuda/)

See GPU Acceleration — either hand-written .cu kernels registered via KernelSources, or plain .NET methods translated to CUDA through IL2Cuda.

JavaScript scripts and the shared library (njs/, libs/)

See The NJS JavaScript Script Engine and Shared Script Libraries. Every tutorial under tutorials/VBS/scripts/<demo>/ has both a .vb and a .js version using the same stdio / stdlib API.

ONNX models and DirectML

See DirectML Compute & ONNX Interop — export a trained CNN, inspect an external .onnx file, evaluate it on the CPU, or compile the same graph into a DirectML session on the GPU.

Data reports

See Unified Data Reporting — build a document from typed Blocks and save it as Markdown, HTML, docx, pdf, rtf or xps without rewriting the content.

Physics and particle simulation (physics/)

PhysicsEngine provides fixed-step 2-D / 3-D rigid-body worlds (collisions, joints, force fields), while Particles adds SoA SPH fluids, boids flocking, an emitter-based 2-D particle system and force-driven label layouts. See Machine Vision & Physics Simulation.

Natural-language processing

TextRank keyword extraction (Microsoft.VisualBasic.Data.NLP.TextRank + NLPExtensions):

Imports Microsoft.VisualBasic.Data.NLP.TextRank
Imports Microsoft.VisualBasic.Data.NLP.NLPExtensions

' Build the TextRank word graph, then rank it with PageRank:
Dim doc As String = IO.File.ReadAllText("paper.txt")
Dim graph = doc.TextGraph()          ' WeightedPRGraph (a GraphMatrix)
Dim keywords = graph.KeyWords()      ' Dictionary(Of String, Double): word -> score

GraphQuery — a GraphQL-like DSL over your .NET objects (Microsoft.VisualBasic.Data.GraphQuery):

Imports Microsoft.VisualBasic.Data.GraphQuery

<GraphQuery("gene")>
Public Class Gene
    <GraphQuery("symbol")> Public symbol As String
    <GraphQuery("length")> Public length As Integer
End Class

' Project only the requested fields from any object graph:
Dim q = GraphQuery.DoQuery("gene { symbol length }")
Dim out = q.From(myGene)

See Data/GraphQuery/README.md and Data/TextRank/README.md for the full reference.

Mathematics & ODEs (Data_science/Mathematica)

Solve a system of ordinary differential equations by subclassing ODEs (namespace Microsoft.VisualBasic.Math.Calculus.Dynamics):

Imports Microsoft.VisualBasic.Math.Calculus.Dynamics
Imports Microsoft.VisualBasic.Math.LinearAlgebra

Public Class Lorenz : Inherits ODEs
    Public x, y, z As var
    Public a As Double = 10
    Public b As Double = 8 / 3
    Public c As Double = 28

    ' Initial values of the state variables.
    Protected Overrides Function y0() As var()
        Return {New var("x", 0), New var("y", 1), New var("z", 0)}
    End Function

    ' The differential equations: dy/dt = f(t, y).
    Protected Overrides Sub func(dx#, ByRef dy As Vector)
        dy(0) = a * (y - x)
        dy(1) = x * (c - z) - y
        dy(2) = x * y - b * z
    End Sub
End Class

' Integrate for 10000 steps over t in [0, 30]:
Dim result = New Lorenz().Solve(10000, 0, 30)
' result.x -> time grid;  result.y -> Dictionary(name -> trajectory)

Machine learning & data mining (Data_science/)

Imports Microsoft.VisualBasic.DataMining.KMeans

' source: IEnumerable(Of T) where T carries a numeric feature vector
' (T : EntityBase(Of Double)).
Dim clusters = New KMeans().ClusterDataSet(source, k:=3)

For i As Integer = 0 To clusters.NumOfCluster - 1
    Dim centroid = clusters(i).ClusterMean()   ' centroid of cluster i
    Console.WriteLine($"cluster {i}: {String.Join(",", centroid)}")
Next

Evolutionary search with Darwinism (genetic algorithm):

Imports Microsoft.VisualBasic.MachineLearning.Darwinism.GAF

' 1. Implement the fitness function (smaller value == better):
Public Class MyFitness : Implements Fitness(Of MyChromosome)
    Public ReadOnly Property Cacheable As Boolean = False
    Public Function Calculate(c As MyChromosome, parallel As Boolean) As Double _
        Implements Fitness(Of MyChromosome).Calculate
        Return -EvaluateModel(c)
    End Function
End Class

' 2. Build a Population(Of MyChromosome) and evolve it generation by generation:
Dim ga As New GeneticAlgorithm(Of MyChromosome)(population, New MyFitness())
For i As Integer = 1 To 500
    ga.Evolve()          ' advance one generation
Next
Dim best = ga.Best       ' the fittest chromosome

Visualization & "Graphics Artist" (Data_science/Visualization, gr/)

Imports Microsoft.VisualBasic.Data.ChartPlots
Imports Microsoft.VisualBasic.Imaging

' 3-D scatter heatmap -> saved as a high-resolution raster image.
Call Plot3D.ScatterHeatmap _
    .Plot(data, size:=New Size(1200, 800)) _
    .Save("scatter3d.png")

' 2-D scatter heatmap.
Call ScatterHeatmap.Plot(points, gridSize:=20).Save("heatmap.png")

' Bar plot directly from a CSV.
Dim bars = csv.LoadBarData("counts.csv")
Call BarPlot.Plot(bars).Save("bars.png")

Network / force-directed layouts and SVG/d3js export are provided by the Microsoft.VisualBasic.Data.visualize.Network and colorbrewer modules — see gr/network-visualization/README.md.

Example for Draw sciBasic Logo

Dim logo As Image, fontName$ = FontFace.Verdana
Dim color1 As New SolidBrush(Color.FromArgb(0, 65, 102))
Dim color2 As New SolidBrush(Color.FromArgb(0, 172, 221))

Using g As IGraphics = DriverLoad.CreateDefaultRasterGraphics(New Size(900, 800), fill_color:=Color.Transparent)
    Dim isometricView As New IsometricEngine(ambientStrength:=0.05, lightIntensity:=0.1)

    isometricView.Add(New Knot(New Point3D(1, 1, 1), scale:=1), GREEN)
    isometricView.Draw(g)

    logo = DirectCast(g, GdiRasterGraphics).ImageResource.CorpBlank(blankColor:=Color.Transparent)
End Using

Using g As IGraphics = DriverLoad.CreateDefaultRasterGraphics(New Size(2400, 500), fill_color:=Color.Transparent)
    Call g.DrawImageUnscaled(logo, New Point(50, 50))

    Call g.DrawString("sci", New Font(fontName, 140), color1, New PointF(430, 90))
    Call g.DrawString("BASIC#", New Font(fontName, 200), color2, New PointF(670, 60))
    Call g.DrawString("http://sciBASIC.NET", New Font(FontFace.SegoeUI, 48), color1, New PointF(720, 350))

    Call g.Flush()

    Call DirectCast(g, GdiRasterGraphics).ImageResource _
        .CorpBlank(blankColor:=Color.Transparent, margin:=30) _
        .SaveAs("logo.png")
End Using

LLM proxy (Microsoft.VisualBasic.LLMs, core)

Imports Microsoft.VisualBasic.LLMs

' Bridge a local Ollama (or any Func(Of String, String)) endpoint in:
HookOllama(Function(prompt) MyLocalModel.Ask(prompt))

' Prompt the hooked model from anywhere in your code:
Dim answer As String = Await LLMsTalk("Explain principal component analysis")

FAQ

Why VisualBasic for scientific computing? Because the language is concise and readable, and sciBASIC# turns it into a productive environment for writing headless, reproducible data-science programs — without giving up the .NET ecosystem.

Are the figures usable in a paper? Yes. The Imaging / ChartPlots engines are tuned for printable, publication-quality output and can export SVG, PDF and high-DPI raster images, which is why sciBASIC# is often described as the "Graphics Artist" for scientific plotting.

Is it cross-platform? Yes. The core and math libraries target net10.0 and run on .NET under Windows, Linux and macOS. The graphics/imaging projects additionally target net10.0-windows. The cuda/ layer requires an NVIDIA GPU and is compiled for x64; DirectML requires Windows with D3D12; everything else runs CPU-only.

Can I write scripts in JavaScript instead of VisualBasic? Yes. The njs host runs JavaScript on the .NET CLR through LiteJs, with a Node-like environment, a REPL and TypeScript .d.ts generation. It shares the exact same stdio / stdlib API with vbs, so demos ship in both .vb and .js forms.

What report formats can I generate? One Block document can be rendered to Markdown, HTML, plain text, docx, pdf, rtf and xps/oxps. Text renderers live in the core runtime; binary document renderers live in the mime/ packages.

Do the deep-learning models need PyTorch/TensorFlow installed? No. All neural networks (CNN/RNN/Transformer/GNN/LNN/SNN/ANFIS/GCN) and the LLM engine are pure managed implementations. ILCudaTensor can transparently move tensor math to an NVIDIA GPU, and ONNX graphs can run through the DirectML backend on Windows; otherwise everything runs on the SIMD-accelerated CPU path.

CLI or GUI? CLI-first and script-first. sciBASIC# is designed for command-line data-science applications — with vbs / njs you can skip the project entirely and just run a .vb or .js file.


Documentation & Contacts

sciBASIC# is licensed under the GNU GPLv3. See the headers in each source file for authorship and copyright details.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…