chipiron.players.boardevaluators.datasets package

Submodules

chipiron.players.boardevaluators.datasets.datasets module

This module contains classes for handling datasets used in board evaluation tasks.

Classes: - MyDataSet: A custom dataset class that loads and preprocesses data. - FenAndValueDataSet: A subclass of MyDataSet that processes raw rows into input and target value tensors.

Functions: - process_stockfish_value: A function that processes the stockfish value for a given board and row.

class chipiron.players.boardevaluators.datasets.datasets.DataSetArgs(train_file_name: Annotated[str | os.PathLike[str], 'path'], test_file_name: Annotated[str | os.PathLike[str], 'path'] | None = None, preprocessing_data_set: bool = False)[source]

Bases: object

preprocessing_data_set: bool = False
test_file_name: str | PathLike[str] | None = None
train_file_name: str | PathLike[str]
class chipiron.players.boardevaluators.datasets.datasets.FenAndValueDataSet(file_name: str | PathLike[str], transform_white_value_to_model_output_function: Callable[[float, IBoard], Tensor], transform_dataset_value_to_white_value_function: Callable[[Series], float], preprocessing: bool = False, transform_board_function: str | BoardToInputFunction = 'identity')[source]

Bases: MyDataSet

A subclass of MyDataSet that processes raw rows into input and target value tensors.

Attributes: - transform_board_function (BoardToInputFunction): The function to transform the board into input tensor. - transform_value_function (callable): The function to transform the value for a given board and row.

Methods: - process_raw_row(row: pandas.Series) -> tuple[torch.Tensor, torch.Tensor]: Processes a raw row into input and target tensors. - process_raw_rows(dataframe: pandas.DataFrame) -> list[tuple[torch.Tensor, torch.Tensor]]: Processes raw rows into input and target tensors.

process_raw_row(row: Series) tuple[Any, torch.Tensor][source]

Processes a raw row into input and target tensors.

Args: - row (pandas.Series): The raw row from the dataset.

Returns: - tuple[torch.Tensor, torch.Tensor]: The input and target tensors.

process_raw_rows(dataframe: DataFrame) list[tuple[torch.Tensor, torch.Tensor]][source]

Processes raw rows into input and target tensors.

Args: - dataframe (pandas.DataFrame): The raw rows from the dataset.

Returns: - list[tuple[torch.Tensor, torch.Tensor]]: The processed input and target tensors.

transform_board_function: BoardToInputFunction
transform_dataset_value_to_white_value_function: Callable[[Series], float]
transform_white_value_to_model_output_function: Callable[[float, IBoard], Tensor]
class chipiron.players.boardevaluators.datasets.datasets.MyDataSet(file_name: str | PathLike[str], preprocessing: bool)[source]

Bases: Dataset[Any]

A custom dataset class that loads and preprocesses data.

Attributes: - file_name (str): The file name of the dataset. - preprocessing (bool): Flag indicating whether to preprocess the dataset. - data (pandas.DataFrame | list[tuple[torch.Tensor, torch.Tensor]] | None): The loaded and processed data. - len (int | None): The length of the dataset.

Methods: - load(): Loads the dataset from the file. - process_raw_row(row: pandas.Series) -> tuple[torch.Tensor, torch.Tensor]: Processes a raw row into input and target tensors.

data: DataFrame | list[tuple[torch.Tensor, torch.Tensor]] | None
get_unprocessed(idx: int) Series[source]
len: int | None
load() None[source]

Loads the dataset from the file.

process_raw_row(row: Series) tuple[torch.Tensor, torch.Tensor][source]

Processes a raw row into input and target tensors.

Args: - row (pandas.Series): The raw row from the dataset.

Returns: - tuple[torch.Tensor, torch.Tensor]: The input and target tensors.

chipiron.players.boardevaluators.datasets.datasets.process_stockfish_value(row: Series) float[source]

Processes the stockfish value for a given board and row.

Args: - board (BoardChi): The chess board. - row (pandas.Series): The row from the dataset.

Returns: - torch.Tensor: The processed target value tensor.

Module contents