Skip to content

student_evaluation_function

guydegnol edited this page Jul 7, 2023 · 10 revisions

📖Description 📎Signature 📜Parameters 📈Examples

Description

This function is used for automatic evaluation. By default, no evaluation is possible. For each cell, a teacher might define one to evaluate an exercice in the cell.

In a cell with the magic method evaluation_cell_id activated, the codes of the student and the codes of the teacher are both run (using the current notebook previous variables). So variables of the cells are available in 2 different contexts: ``teacher student`.

Signature

  • Python:
student_evaluation_function(max_score=10, min_score=0, debug=False, run=False, show_code=False)
  • C++:
student_evaluation_function(int max_score=10, int min_score=10, bool debug=false, bool run=false, bool show_code=false)

Parameters

  • min_score: min_score of a student for this exercice
  • max_score: max_score of a student for this exercice
  • debug: run in debug mode
  • run: automatically run the code for the current cell
  • show_code: show the code of the evaluation method

Returns

  • score: the student score, a float between min_score and max_score.

Examples

  • Example 1
m_test = np.array([[0., 3, 4], [1, 6, 4]])
num_px = [1, 3]
m_train = np.array([[0., 3, 5], [1, 6, 4]])
iterations = 1990
print("This is my standard output")

def student_evaluation_function(max_score=10, debug=False, run=False, run=False):
    score = 1
    cost = 0.9525741268
    score += bulkhours.is_equal(student.m_test, max_score=1)
    score += bulkhours.is_equal(data_test=student.num_px, max_score=1)
    score += bulkhours.is_equal(data_test=student.m_train, teacher.m_train, max_score=1)
    score += bulkhours.is_equal(cost, data_ref=0.9525741268, max_score=1)
    score += bulkhours.is_equal(student.iterations, data_ref=2000, policy="gaussian", error=1e-8, max_score=1)

    # Compare standard outputs of student and teacher executions. Strings distances are estimated using a Ratcliff-Obershelp algorithm
    score += bulkhours.is_equal(student.stdout, teacher.stdout, policy="gaussian", error=0.2, max_score=1)

    return score
  • Example 2
data_test = image2vector(image)

def student_evaluation_function():
    data_ref = np.array([[0.67826139, 0.29380381, 0.90714982]])
    score = 0
    if np.max(np.abs(student.data_test-data_ref)) < 0.001:
        score += 2
    # Should be the same test than the previous one, assuming, teacher.my_tested_data = data_ref
    if np.max(np.abs(student.my_tested_data-teacher.my_tested_data)) < 0.001:
        score += 2
    return score
  • Example 3
%%evaluation_cell_id -i cpp -w scoa -l Construire une suite géométrique de raison 2 en C++, de 2 a 1024
%%compile_and_exec -c g++
#include <iostream>

int main() {
    int pow2 = 1;
    for (int i = 1; i < 10; ++i)
    {
      pow2 *= 2;
      std::cout << pow2 << " ";
    }
}

float student_evaluation_function(bool debug=false, bool run=false, bool show_code=false) {
    return bulkhours.is_equal(student.stdout, teacher.stdout, policy="gaussian", error=0.1);
}

Clone this wiki locally