def conf_matrix(rows_grid, columns_grid):
    """compute the confusion matrix (as counts) from grids of active classes.

    See :func:`ChildProject.metrics.segments_to_grid` for a description of grids.

    :param rows_grid: the grid corresponding to the rows of the confusion matrix.
    :type rows_grid: numpy.array
    :param columns_grid: the grid corresponding to the columns of the confusion matrix.
    :type columns_grid: numpy.array
    :param categories: the labels corresponding to each class
    :type categories: list of strings
    :return: a square numpy array of counts
    :rtype: numpy.array
    """
    return rows_grid.T @ columns_grid