ml_logistic_regression 0.0.1
ml_logistic_regression: ^0.0.1 copied to clipboard
A lightweight, stable and trainable Logistic Regression package in pure Dart. Supports sigmoid prediction, L2 regularization, and classification thresholds.
import 'package:ml_logistic_regression/ml_logistic_regression.dart';
void main() {
final model = LogisticRegression(
learningRate: 0.1,
iterations: 1000,
regularization: 0.01,
threshold: 0.5,
);
final inputs = [
[0.0, 0.0],
[0.0, 1.0],
[1.0, 0.0],
[1.0, 1.0],
];
final labels = [0, 0, 0, 1];
model.fit(inputs, labels);
print(model);
final preds = model.predict(inputs);
final probs = model.predictProba(inputs);
for (int i = 0; i < inputs.length; i++) {
print('Input: ${inputs[i]} → Label: ${labels[i]} → Predicted: ${preds[i]} → Prob: ${probs[i].toStringAsFixed(3)}');
}
}