Skip to main content

BIRTGD is an implementation of Beta3-irt using gradient descent.

Project description

license: MIT Docs Author Author2

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) = (θij)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)
  • seaborn (>=0.11.0)
  • matplotlib (>=3.3.2)
  • scikit-learn (>=0.23.2)

User installation

pip install 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
>>> data = pd.DataFrame({'a': [0.99,0.89,0.87], 'b': [0.32,0.25,0.45]})
>>> bgd = BIRTGD(n_models=2, n_instances=3, random_seed=1)
>>> bgd.fit(data)
100%|██████████| 5000/5000 [00:22<00:00, 219.50it/s]
<birt.BIRTGD at 0x7f6131326c10>
>>> bgd.abilities
array([0.90438306, 0.27729774], dtype=float32)
>>> bgd.difficulties
array([0.3760659 , 0.5364428 , 0.34256178], dtype=float32)
>>> bgd.discriminations
array([1.6690203 , 0.9951777 , 0.65577406], dtype=float32)

Summary data

How to use the summary feature:

  • Generate data
import numpy as np
import matplotlib.pyplot as plt

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()
        ESTIMATES
        -----
                        | 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 Scatterplot Feature

birt.plot(xaxis='discrimination',yaxis='difficulty', ann=True, kwargs={'color': 'red'})
plt.show()
assets/dis_diff_ex.png
birt.plot(xaxis='difficulty',yaxis='average_item', ann=True, kwargs={'color': 'red'})
plt.show()
assets/diff_av_ex2.png
birt.plot(xaxis='ability',yaxis='average_response', ann=False)
plt.show()
assets/ab_av_ex3.png

Using Boxplot Feature

birt.boxplot(y='abilities',kwargs={'linewidth': 4})
assets/ab_av_ex4.png
birt.boxplot(x='difficulties')
assets/ab_av_ex5.png
birt.boxplot(y='discriminations')
assets/ab_av_ex6.png

Help and Support

Communication

License

MIT License

Copyright (c) 2021 Manuel Ferreira Junior

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

birt-gd-0.1.16.tar.gz (12.0 kB view hashes)

Uploaded Source

Built Distribution

birt_gd-0.1.16-py3-none-any.whl (10.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page