BIRTGD is an implementation of Beta3-irt using gradient descent.
Project description
birt-gd
BIRTGD is an implementation of Beta3-irt using gradient descent.
The model expects to receive two sets of data, X being a list or array containing tuples of indices, where the first index references the instance j and the second index of the tuple references the model i, thus, Y will be a list or array where each input will be pij ~ Β(αij, βij), the probability of the i model correctly classifying the j model. Being,
pij ~ Β(αij, βij)
αij = Fα(θi, δj, aj) = (θi/δj)aj
βij = Fβ(θi, δj, aj) = ( (1 - θi)/(1 - δj) )aj
θi ~ Β(1,1), δj ~ Β(1,1), aj ~ N(1, σ20)
where,
E[pij | θi, δj, aj] = (αij)/( αij + βij) = 1/(1 + ( (δj)/(1 - δj) )aj × ( (θi)/(1 - θi) ) - aj )
Installation
Dependencies
birt-sgd requires:
- Python (>=3.8.5)
- numpy (>=1.19.5)
- tqdm (>=4.59.0)
- tensorflow (>=2.4.1)
- pandas (>=1.2.3)
User installation
pip install -i https://test.pypi.org/simple/ birt-gd
Source code
You can check the code with
git clone https://github.com/Manuelfjr/birt-gd
Usage
Import the BIRTGD's class
>>> from birt import BIRTGD
>>> X = [(0,0),(0,1),(0,2),(1,0),(1,1),(1,2)]
>>> Y = [0.98,0.81,0.12,0.567,0.76,0.9]
>>> bgd = BIRTGD(n_models=3, n_instances=2, random_seed=1)
>>> bgd.fit(X,Y)
100%|██████████| 20/20 [00:00<00:00, 52.81it/s]
<birt.BIRTGD at 0x7f6ce2555f50>
>>> bgd.abilities
array([0.78665066, 0.5025896 , 0.545207], dtype=float32)
>>> bgd.difficulties
array([0.25070453, 0.46883535], dtype=float32)
>>> bgd.discriminations
array([0.09374281, 1.4122988 ], dtype=float32)
Summary data
How to use the summary feature:
- Generate data
import numpy as np
m, n = 5, 20
np.random.seed(1)
abilities = [np.random.beta(1,i) for i in ([0.1, 10] + [1]*(m-2))]
difficulties = [np.random.beta(1,i) for i in [10, 5] + [1]*(n-2)]
discrimination = list(np.random.normal(1,1, size=n))
pij = pd.DataFrame(columns=range(m), index=range(n))
- Fitting the model
birt = BIRTGD(n_models=pij.shape[1],
n_instances=pij.shape[0],
learning_rate=1,
epochs=5000,
n_inits=1000)
birt.fit(pij)
- Summary
birt.summary()
HYPERPARAMS
-----
| Min 1Qt Median 3Qt Max Std.Dev
Ability | 0.00010 0.22148 0.63389 0.73353 0.92040 0.33960
Difficulty | 0.01745 0.28047 0.63058 0.84190 0.98624 0.31635
Discrimination | 0.31464 1.28330 1.61493 2.22936 4.44645 1.02678
pij | 0.00000 0.02219 0.35941 0.86255 0.99993 0.40210
-----
Pseudo-R2 | 0.90381
Using Plot Feature
birt.plot(xaxis='discrimination',yaxis='difficulty', ann=True, kwargs={'color': 'red'})
birt.plot(xaxis='difficulty',yaxis='average_item', ann=True, kwargs={'color': 'red'})
birt.plot(xaxis='ability',yaxis='average_response', ann=False)
Help and Support
Communication
- E-mail: ferreira.jr.ufpb@gmail.com
- Site: https://manuelfjr.github.io/
License
Copyright (c) 2021 Manuel
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file birt-gd-0.1.6.tar.gz
.
File metadata
- Download URL: birt-gd-0.1.6.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.6.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 304e4958ff773542ada1dc912859e149890130e853e28bf0533924f95ba1f525 |
|
MD5 | c96da0553155a6e1ce4ec250d1352a54 |
|
BLAKE2b-256 | 98ec741717612a6417f244b78c0e3a5a6f9b141e844a42b16e44dabc9bdda6cc |
Provenance
File details
Details for the file birt_gd-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: birt_gd-0.1.6-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.6.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f773e308a29a9791ea4e38bb94cc76dbe5a65403363fc8b2a2dcc03b06498e2b |
|
MD5 | 7d630820706e8cfcfc04f75cefdf1dda |
|
BLAKE2b-256 | 8acccd8bf1ef2a06458f38bea3e4555cc3b69beeb77d372ce1d7cce11a2d67b8 |