Appendix

Models

class lain.ErrorModel(*args, **kwargs)[source]

A model for osu! which trains on windows of time events and attempts to predict the user’s aim and accuracy error for each circle.

Parameters:

context : int

The number of leading and trailing hit objects or slider ticks to look at.

aim_pessimism_factor : float

An exponential increase in aim error to account for the fact that most replays are heavily biased towards a user’s best replays.

accuracy_pessimism_factor : float

An exponential increase in accuracy error to account for the fact that most replays are heavily biased towards a user’s best replays.

trailing_context : int

The number of leading trailing hit objects or slider ticks to look at.

forward_context : int

The number of forward hit objects or slider ticks to look at.

hidden_layer_sizes : tuple[int, int]

The sizes of the hidden layers.

dropout : float

The droput ratio.

activation : str

The activation function. Must be one of: ‘tanh’, ‘softplus, ‘softsign’, ‘relu’, ‘sigmoid’, ‘hard_sigmoid’, or ‘linear’.

loss : {‘mse’, ‘mae’, ‘mape’, ‘male’, ‘cosine’

The loss function.

optimizer : str

The optimizer to use.

max_hit_objects : int

The maximum number of hit objects allows in a beatmap. Data will be padded to fit this shape.

fit(replays, *, verbose=False, epochs=10)[source]

Fit the model to data.

Parameters:

replays : iterable[sl.Replay]

The replays to fit the model to.

verbose : bool, optional

Print verbose messages to stdout?

epochs : int, optional

The number of times to pass through the replays.

Returns:

hidden_history : keras.History

The history of training the keras model on the replays with hidden.

non_hidden_history : keras.History

The history of training the keras model on the replays without hidden.

classmethod load_path(path)[source]

Deserialize a model from a directory.

Parameters:

path : path-like

The path to the directory to load.

Returns:

self : lain.ErrorModel

The loaded model.

predict(beatmap, *, pessimistic=True, hidden=False, double_time=False, half_time=False, hard_rock=False, random_state=None, samples=1000)[source]

Predict the user’s accuracy on the beatmap with the given mods.

Parameters:

beatmap : sl.Beatmap

The beatmap to predict.

pessimistic : bool, optional

Apply pessimistic error scaling?

hidden : bool, optional

Predict performance with hidden?

double_time : bool, optional

Predict performance with double time?

half_time : bool, optional

Predict performance with half time?

hard_rock : bool, optional

Predict performance with hard rock?

random_state : np.random.RandomState, optional

The numpy random state used to draw samples.

samples : int, optional

The number of plays to simulate.

Returns:

prediction : Prediction

A collection of predicted values for this play.

save_path(path)[source]

Serialize the model as a directory.

Parameters:

path : path-like

The path to the directory to serialize the model to.

class lain.error_model.Prediction(*, predicted_aim_error, predicted_aim_distribution, predicted_accuracy_error, predicted_accuracy_distribution, accuracy_mean, accuracy_std, pp_mean, pp_std)[source]

The model’s predicted values.

Attributes

predicted_aim_error (np.ndarray[float64]) The predicted aim errors for each object.
predicted_aim_distribution (scipy.stats.lognorm) The predicted distribution of aim errors.
predicted_accuracy_error (np.ndarray[float64]) The predicted accuracy errors for each object.
predicted_accuracy_distribution (scipy.stats.lognorm) The predicted distribution of accuracy errors.
accuracy_mean (float) The mean predicted accuracy.
accuracy_std (float) The standard deviation of the predicted accuracy.
pp_mean (float) The mean predicted performance points.
pp_std (float) The standard deviation of the predicted performance points.

Utilities

class lain.Scaler(ndim)[source]

Scaler for feature arrays.

Parameters:

ndim : int

The number of dimensions of the feature arrays.

fit(data)[source]

Fit the scaler to the data.

Parameters:

data : np.ndarray

The data to fit the scaler to.

Returns:

transformed : np.ndarray

The transformed input data.

invert(scaled_data)[source]

Invert the scaling for some data.

Parameters:

scaled_data : np.ndarray

The scaled data.

Returns:

data : np.ndarray

The pre-transformed data.

transform(data)[source]

Scale data based on the fit data.

Parameters:

data : np.ndarray

The data to transform.

Returns:

transformed : np.ndarray

The transformed input data.

lain.load_replay_directory(path, *, library=None, client=None, age=None, save=False, verbose=False)[source]

Load all eligible replays from a directory.

Parameters:

path : str or pathlib.Path

The path to the directory of .osr files.

library : Library, optional

The beatmap library to use when parsing the replays.

client : Client, optional

The client to use when parsing the replays.

age : datetime.timedelta, optional

Only count replays less than this age old.

save: bool, optional

If the beatmap does not exist, and a client is used to fetch it, should the beatmap be saved to disk?

verbose : bool, optional

Print error information to stderr?

Yields:

replay : Replay

The eligible replays in the directory.

Notes

The same beatmap may appear more than once if there are multiple replays for this beatmap.