Skip to content

Commit

Permalink
Documentation and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
XPerianer committed Nov 28, 2023
1 parent b7dcf05 commit b7a9e3c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ and the Flutter guide for

[![Dart CI](https://github.com/XPerianer/Bandart/actions/workflows/test-package.yml/badge.svg)](https://github.com/XPerianer/Bandart/actions/workflows/test-package.yml)

Bandart (combination of "Bandits" and "Dart") is a library for bandit algorithms in Dart. It provides Bayesian Models for statistical analysis for the data.
Bandart (combination of "Bandits" and "Dart") is a library for bandit algorithms in Dart.
It provides Bayesian Models for statistical analysis for the data.

## Features
- Bandit algorithms:
Expand All @@ -24,6 +25,7 @@ Bandart (combination of "Bandits" and "Dart") is a library for bandit algorithms
- Gaussian Model: Approximating mean and variance using conjugate priors



## Getting started

Install the package using ```dart pub add bandart```.
Expand Down Expand Up @@ -63,7 +65,6 @@ gaussianModel.history = history
// Update the samples
gaussianModel.sample()
// Look at the results
print(gaussianModel.maxProbabilities())
// Prints around [0.2, 0.8]
```
Expand All @@ -82,8 +83,8 @@ var gaussianModel = GaussianModel(
var policy = ThompsonSampling(numberOfInterventions: 2);
// Prints either 0 or 1 (randomized), but will more often pick 1 as this is the intervention with the better history
print(policy.choseAction({}, history));
// Prints either 0 or 1 (randomized), but will more often pick 1 as this is the intervention with the better history
```

Expand All @@ -100,9 +101,4 @@ To update the mock code, run ```dart run build_runner build```.
- Performance: Since Dart is most often used for mobile development, the goal of the library is to support calculations fast enough to run on smartphones.
- Seedability: When seeded with the same seed, the library should always return the same result.
- Well tested
- Extensible
-

TODO: Tell users more about the package: where to find more information, how to
contribute to the package, how to file issues, what response they can expect
from the package authors, and more.
3 changes: 2 additions & 1 deletion lib/bandart.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// Library for Bandit Algorithms with underlying Bayesian Models
library bandart;

export 'src/dataframe.dart' show DataFrame;
Expand All @@ -9,4 +10,4 @@ export 'src/models/gaussian.dart' show GaussianModel;

export 'src/policies/policy.dart' show Policy;
export 'src/policies/fixed_policy.dart' show FixedPolicy;
export 'src/policies/thompson_sampling.dart' show ThompsonSampling;
export 'src/policies/thompson_sampling.dart' show ThompsonSampling;
1 change: 1 addition & 0 deletions lib/helpers.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// Collections of helpful functions to write easier code.
library helpers;

export 'src/helpers.dart';
1 change: 1 addition & 0 deletions lib/src/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:math';

import 'package:collection/collection.dart';

/// Returns the index of the largest element in the list
int argMax<T extends num>(List<T> list) {
return list
.asMap()
Expand Down
3 changes: 3 additions & 0 deletions lib/src/policies/thompson_sampling.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import 'dart:math';
import 'package:bandart/bandart.dart';
import 'package:bandart/helpers.dart';

/// ThompsonSampling is a policy that picks an intervention based on the probability of it being the best intervention.
///
/// For example: If the probability of intervention 0 beeing the best intervention is 0.8, then ThompsonSampling will pick intervention 0 with a probability of 0.8.
class ThompsonSampling implements Policy {
final SamplingModel model;
final Random random;
Expand Down

0 comments on commit b7a9e3c

Please sign in to comment.