# LinUCBDisjoint

LinUCB, disjoint variant.

Although it works, as of yet it is too slow to realistically be used in practice.

The way this works is that each arm is assigned a [`linear_model.BayesianLinearRegression`](<https://riverml.xyz/0.27.0/api/linear-model/BayesianLinearRegression>) instance. This instance is updated every time the arm is pulled. The context is used as features for the regression. The reward is used as the target. The posterior distribution is used to compute the upper confidence bound. The arm with the highest upper confidence bound is pulled.

## Parameters

- **alpha**

  *Type* → `float`

  *Default* → `1.0`

  Parameter used in each Bayesian linear regression.
- **beta**

  *Type* → `float`

  *Default* → `1.0`

  Parameter used in each Bayesian linear regression.
- **smoothing**

  *Type* → `float | None`

  *Default* → `None`

  Parameter used in each Bayesian linear regression.
- **reward\_obj**

  *Default* → `None`

  The reward object used to measure the performance of each arm.
- **burn\_in**

  *Default* → `0`

  The number of time steps during which each arm is pulled once.
- **seed**

  *Type* → `int | None`

  *Default* → `None`

  Random number generator seed for reproducibility.

## Attributes

- **ranking**

  Return the list of arms in descending order of performance.

## Methods

> [!NOTE]
>
> **pull**
>
> Pull arm(s).
>
> This method is a generator that yields the arm(s) that should be pulled. During the burn-in phase, all the arms that have not been pulled enough times are yielded. Once the burn-in phase is over, the policy is allowed to choose the arm(s) that should be pulled. If you only want to pull one arm at a time during the burn-in phase, simply call `next(policy.pull(arms))`.
>
> **Parameters**
>
> - **arm\_ids** — `list[ArmID]`
> - **context** — `dict | None` — defaults to `None`
>
> **Returns**
>
> `ArmID`: A single arm.

> [!NOTE]
>
> **update**
>
> Rewrite update function.
>
> **Parameters**
>
> - **arm\_id**
> - **context**
> - **reward\_args**
> - **reward\_kwargs**

## References

- [Li, L., Chu, W., Langford, J. and Schapire, R.E., 2010, April. A contextual-bandit approach to personalized news article recommendation. In Proceedings of the 19th international conference on World wide web (pp. 661-670).](<https://doi.org/10.1145/1772690.1772758>)
- [Contextual Bandits Analysis of LinUCB Disjoint Algorithm with Dataset](<https://kfoofw.github.io/contextual-bandits-linear-ucb-disjoint/>)
