File size: 1,252 Bytes
8ab6a5f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from abc import ABC, abstractmethod

import pandas as pd


class BaseTask(ABC):
    """Base class for all data analysis tasks.

    Subclasses must implement the question, compute the expected answer
    from the dataset, and provide a grading function.

    Attributes:
        df: The pandas DataFrame containing the dataset.
    """

    def __init__(self, df: pd.DataFrame):
        self.df = df

    @property
    @abstractmethod
    def task_id(self) -> int:
        """Return the unique task identifier."""

    @property
    @abstractmethod
    def difficulty(self) -> str:
        """Return the difficulty level: 'easy', 'medium', or 'hard'."""

    @property
    @abstractmethod
    def description(self) -> str:
        """Return the task question shown to the agent."""

    @abstractmethod
    def expected_answer(self) -> str:
        """Compute and return the ground-truth answer from the dataset.

        Returns:
            The expected answer as a formatted string.
        """

    @abstractmethod
    def grade(self, answer: str) -> float:
        """Grade the agent's submitted answer.

        Args:
            answer: The agent's submitted answer string.

        Returns:
            A score between 0.0 and 1.0.
        """