std.ml_full
Erweiterte Machine-Learning-Algorithmen und Modelle: Deep Learning Layers, Convolutional Networks, Rekurrente Netze (LSTM), Gradient Boosting und Ensemble-Methoden. Aufbauend auf std.ml mit schwergewichtigen Implementierungen für Produktionseinsatz.
→ std.ml · Standard Library · std.graphdb
Die Doppel vonExpF64,LogF64undSqrtF64sind entfernt (#1572 behoben). Die Unit importiert jetztstd.math; wer sie mitimportiert, bekommt dieselben Werte wie überall sonst — mit 1.1.2E nachgemessen:
LogF64(100) = 4.605170 ExpF64(1) = 2.718281
Vorher lieferteLogF64hier immer 0 undExpF64eine grobe Näherung, ohne jede Meldung — und zwar im ganzen Programm, weil die Namen im flachen Namensraum kollidierten.
Typen
DecisionTreeNode (struct)
| Feld | Typ |
|---|---|
featureIdx | int64 |
threshold | f64 |
left | int64 |
right | int64 |
classLabel | int64 |
nSamples | int64 |
impurity | f64 |
featureImportance | f64 |
Funktionen
| Signatur | Sichtbarkeit | Beschreibung |
|---|---|---|
SquareF64(x: f64): f64 | pub | — |
SqrtF64(x: f64): f64 | pub | SSE2-optimized square root (uses sqrtsd when available) Currently falls back to Newton's method |
SqrtF64SSE(x: f64): f64 | pub | — |
ExpF64(x: f64): f64 | pub | Exponential function - simple approximation exp(x) ≈ 1 + x for small x, use lookup for common values |
SigmoidF64(z: f64): f64 | pub | Sigmoid function: σ(z) = 1 / (1 + e^(-z)) Use piecewise approximation |
LogF64(x: f64): f64 | pub | Log (natural logarithm) - inverse of exp |
LinearRegressionInit(): void | pub | Initialize model - with small non-zero weights |
LinearRegressionWeight(): f64 | pub | Get weight |
LinearRegressionBias(): f64 | pub | Get bias |
LinearRegressionLoss(): f64 | pub | Get last loss |
LinearRegressionEpochs(): int64 | pub | Get epochs |
LinearRegressionPredict(x: f64): f64 | pub | Predict single value (linear) |
LogisticRegressionInit(): void | pub | Initialize logistic regression model |
LogisticRegressionWeight(): f64 | pub | Get weight |
LogisticRegressionBias(): f64 | pub | Get bias |
LogisticRegressionLoss(): f64 | pub | Get last loss (binary cross-entropy) |
LogisticRegressionAccuracy(): f64 | pub | Get accuracy |
LogisticRegressionEpochs(): int64 | pub | Get epochs |
LogisticRegressionPredictProb(x: f64): f64 | pub | Predict probability (sigmoid output) Returns value between 0 and 1 |
LogisticRegressionPredict(x: f64): int64 | pub | Predict class (binary: 0 or 1) Returns 0 if prob < 0.5, else 1 |
LinearRegressionFitDataFrame(df: int64, xCol: int64, yCol: int64): void | pub | df: DataFrame pointer xCol: column name for feature (int64 pointer) yCol: column name for target (int64 pointer) |
LinearRegressionDataPointCount(): int64 | pub | Get number of data points from last DataFrame fit |
LogisticRegressionFitDataFrame(df: int64, xCol: int64, yCol: int64, learningRate: f64, epochs: int64): void | pub | DataFrame-based Logistic Regression (arbitrary data points) Train Logistic Regression from DataFrame |
LinearRegressionFitArrays(xData: int64, yData: int64, n: int64): void | pub | xData: pointer to f64 array (x values) yData: pointer to f64 array (y values) n: number of data points |
LogisticRegressionFitArrays(xData: int64, yData: int64, n: int64, learningRate: f64, epochs: int64): void | pub | Array-based Logistic Regression (arbitrary data points) Train Logistic Regression from f64 arrays |
KNNInit(k: int64): void | pub | Initialize k-NN model k: number of neighbors (usually odd: 1, 3, 5, 7…) |
KNNGetK(): int64 | pub | Get k value |
KNNGetNSamples(): int64 | pub | Get number of training samples |
KNNFit(features: int64, labels: int64, n: int64, nFeatures: int64): void | pub | labels: pointer to labels array (n labels) n: number of training samples nFeatures: number of features per sample |
KNNDistance(a: int64, b: int64, n: int64): f64 | pub | Euclidean distance between two feature vectors |
KNNDistanceSSE(a: int64, b: int64, n: int64): f64 | pub | SSE-optimized Euclidean distance (future: uses AVX) |
KNNManhattanDistance(a: int64, b: int64, n: int64): f64 | pub | Manhattan distance (L1) |
KNNFindNeighbors(query: int64, k: int64): int64 | pub | Find k nearest neighbors (indices array) |
KNNMajorityVote(neighborIndices: int64, k: int64): int64 | pub | Majority vote |
KNNWeightedVote(neighborIndices: int64, query: int64, k: int64): int64 | pub | Weighted majority vote |
KNNPredict(query: int64): int64 | pub | Predict class |
KNNPredictProba(query: int64, nClasses: int64): int64 | pub | Predict probabilities |
KNNCrossValidation(features: int64, labels: int64, n: int64, nFeatures: int64, k: int64, folds: int64): f64 | pub | Cross-validation |
KNNScore(features: int64, labels: int64, n: int64): f64 | pub | Score on training set |
KMeansInit(k: int64): void | pub | Cluster centroid vector Note: stored as contiguous f64 array at km_centroids Initialize k-Means |
KMeansGetK(): int64 | pub | Get number of clusters |
KMeansGetIter(): int64 | pub | Get current iteration |
KMeansGetInertia(): f64 | pub | Get inertia (sum of squared distances) |
KMeansInitCentroids(features: int64, n: int64, nFeatures: int64, k: int64): void | pub | Initialize centroids using k-means++ algorithm |
KMeansFit(features: int64, n: int64, nFeatures: int64, k: int64): void | pub | n: number of samples nFeatures: number of features k: number of clusters |
KMeansPredictCluster(point: int64): int64 | pub | Get cluster assignment for a point |
KMeansGetAssignments(): int64 | pub | Get all cluster assignments |
KMeansGetCentroids(): int64 | pub | Get cluster centroids |
KMeansGetClusterSize(clusterIdx: int64): int64 | pub | Get cluster size |
KMeansGetCentroid(idx: int64, featureIdx: int64): f64 | pub | Get centroids as array (for visualization) |
KMeansSilhouette(features: int64, n: int64, nFeatures: int64): f64 | pub | Calculate silhouette score (quality metric) |
KMeansElbow(features: int64, n: int64, nFeatures: int64, maxK: int64): int64 | pub | Elbow method: calculate inertia for different k values |
KMeansMiniBatchInit(k: int64, batchSize: int64): void | pub | Initialize mini-batch k-means |
KMeansMiniBatchFit(features: int64, n: int64, nFeatures: int64, k: int64): void | pub | Fit mini-batch k-means (faster approximation) |
NaiveBayesInit(nClasses: int64, vocabSize: int64): void | pub | Initialize Naive Bayes |
NaiveBayesFit(documents: int64, docLengths: int64, labels: int64, n: int64): void | pub | docLengths: lengths of each document labels: class label for each document n: number of documents |
NBLog(x: f64): f64 | pub | Log function approximation |
NaiveBayesPredict(docWords: int64, docLen: int64): int64 | pub | Predict class for a document |
NaiveBayesPredictProba(docWords: int64, docLen: int64): int64 | pub | Predict probabilities for all classes |
NaiveBayesGetWordCount(classIdx: int64, wordIdx: int64): f64 | pub | Get word count for class |
NaiveBayesGetClassCount(classIdx: int64): int64 | pub | Get class count |
NaiveBayesScore(documents: int64, docLengths: int64, labels: int64, n: int64): f64 | pub | Score on training data |
NaiveBayesBernoulliInit(nClasses: int64, vocabSize: int64): void | pub | Initialize Bernoulli Naive Bayes |
NaiveBayesBernoulliFit(documents: int64, docLengths: int64, labels: int64, n: int64): void | pub | Bernoulli NB training |
NaiveBayesBernoulliPredict(docWords: int64, docLen: int64): int64 | pub | Bernoulli NB prediction (with complement) |
DecisionTreeInit(maxDepth: int64, criterion: int64): void | pub | Initialize Decision Tree |
DTGiniImpurity(labels: int64, n: int64): f64 | pub | Calculate Gini impurity |
DTEntropyImpurity(labels: int64, n: int64): f64 | pub | Calculate Entropy impurity |
DTMSEImpurity(values: int64, n: int64): f64 | pub | Calculate MSE impurity (for regression) |
DecisionTreePredict(featureVector: int64): int64 | pub | Predict using Decision Tree |
DecisionTreePredictProba(featureVector: int64, nClasses: int64): int64 | pub | Predict probabilities |
DecisionTreeScore(features: int64, labels: int64, n: int64): f64 | pub | Score Decision Tree |
DecisionTreeGetDepth(): int64 | pub | Get tree depth |
DecisionTreeGetNLeafs(): int64 | pub | Get number of leaf nodes (approximation) |
Signaturen automatisch aus std/ml_full.lyx erzeugt (Stand 2026-08-02, lyxc 1.0.21A). Beschreibungen stammen aus den Quellkommentaren und sind teilweise unvollständig.
