{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# National mathematics example\n", "Here we provide a usage example of the IRTorch package using data from the national mathematics test for Swedish high school students. We will not do an in-depth analysis of the data, but rather showcase some of the main features of IRTorch to enable the user to analyze their own data.\n", "\n", "Users are referred to the API reference section of the documentation for more detailed information of different functions and classes. Note that the results might vary slightly from those presented here due to differences in the computing hardware (CPU or GPU), the operating system, and the versions of the packages used.\n", "\n", "If you prefer to run the code directly, you can download this example Jupyter notebook from the [GitHub repository](https://github.com/joakimwallmark/irtorch/blob/main/docs/source/notebooks/national_mathematics.ipynb)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load the libraries\n", "We start by loading the libraries and modules that we will use for this example." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import torch\n", "import irtorch\n", "from irtorch.models import GeneralizedPartialCredit, MonotoneNN\n", "from irtorch.rescale import Bit\n", "from irtorch.estimation_algorithms import MML, JML" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
| \n", " | a1 | \n", "b1 | \n", "b2 | \n", "b3 | \n", "b4 | \n", "
|---|---|---|---|---|---|
| 0 | \n", "2.529953 | \n", "-2.310085 | \n", "-0.000000 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 1 | \n", "1.188545 | \n", "-1.011769 | \n", "-0.000000 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 2 | \n", "1.860119 | \n", "-1.501075 | \n", "-0.000000 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 3 | \n", "1.052285 | \n", "-0.625713 | \n", "-0.000000 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 4 | \n", "1.358516 | \n", "-0.085676 | \n", "-0.000000 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 5 | \n", "0.729730 | \n", "-0.871447 | \n", "-0.000000 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 6 | \n", "1.213311 | \n", "0.198134 | \n", "-0.000000 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 7 | \n", "1.190133 | \n", "-2.031975 | \n", "-0.000000 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 8 | \n", "0.979525 | \n", "-0.088714 | \n", "-0.000000 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 9 | \n", "1.132489 | \n", "0.237387 | \n", "-0.309951 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 10 | \n", "1.306803 | \n", "-0.260316 | \n", "-0.684906 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 11 | \n", "1.598211 | \n", "-1.347207 | \n", "-0.697698 | \n", "0.439783 | \n", "-0.000000 | \n", "
| 12 | \n", "1.484667 | \n", "-1.209232 | \n", "-1.526546 | \n", "0.777015 | \n", "-0.000000 | \n", "
| 13 | \n", "1.117311 | \n", "0.654208 | \n", "1.539641 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 14 | \n", "1.553362 | \n", "0.235789 | \n", "2.699686 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 15 | \n", "0.807890 | \n", "-0.351218 | \n", "-0.873549 | \n", "-0.795557 | \n", "-1.548087 | \n", "
| 16 | \n", "1.265904 | \n", "0.852304 | \n", "0.748650 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 17 | \n", "1.582821 | \n", "-0.245806 | \n", "-0.336996 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 18 | \n", "1.607533 | \n", "0.016159 | \n", "0.909183 | \n", "2.093414 | \n", "-0.000000 | \n", "
| 19 | \n", "1.376165 | \n", "2.389322 | \n", "3.884833 | \n", "4.636078 | \n", "4.936493 | \n", "
| 20 | \n", "1.596748 | \n", "-1.485482 | \n", "-2.106120 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 21 | \n", "1.107210 | \n", "-0.354539 | \n", "-1.929718 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 22 | \n", "1.057379 | \n", "-0.732737 | \n", "-0.312110 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 23 | \n", "1.893040 | \n", "0.048051 | \n", "1.340048 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 24 | \n", "0.665695 | \n", "0.618374 | \n", "1.081607 | \n", "1.269795 | \n", "0.737873 | \n", "
| 25 | \n", "2.557212 | \n", "1.350395 | \n", "2.525016 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 26 | \n", "1.396081 | \n", "1.874109 | \n", "2.792426 | \n", "-0.000000 | \n", "-0.000000 | \n", "
| 27 | \n", "1.275226 | \n", "2.305732 | \n", "4.095278 | \n", "5.066998 | \n", "6.079602 | \n", "