def precision(self, scores: Union[List[float], List[List]], threshold=0.5):
        """
        Calculates precision given true labels and model-generated scores.

        Parameters:
        - scores (list of float): A list of model-generated scores (0 to 1.0).
        - threshold (float): The threshold to convert scores to binary predictions. Default is 0.5.

        Returns:
        - float: The precision score.
        """
        if isinstance(scores[0], List):
            scores = [score for score, _ in scores]

        # Convert scores to binary predictions based on the threshold
        predictions = [1 if score >= threshold else 0 for score in scores]

        # Calculate true positives and false positives
        true_positives = sum(
            1
            for true, pred in zip(self.true_labels, predictions)
            if true == 1 and pred == 1
        )
        false_positives = sum(
            1
            for true, pred in zip(self.true_labels, predictions)
            if true == 0 and pred == 1
        )

        # Handle the case where there are no predicted positives to avoid division by zero
        if true_positives + false_positives == 0:
            return 0.0  # or handle as needed (e.g., return None, raise an exception)

        # Calculate precision
        precision = true_positives / (true_positives + false_positives)
        return precision

        Calculates precision given true labels and model-generated scores.

        Parameters:
        - scores (list of float): A list of model-generated scores (0 to 1.0).
        - threshold (float): The threshold to convert scores to binary predictions. Default is 0.5.

        Returns:
        - float: The precision score.
        
src/feedback/trulens/feedback/groundtruth.py