Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Python ergonomics #65

Merged
merged 3 commits into from
Apr 11, 2024
Merged

Improved Python ergonomics #65

merged 3 commits into from
Apr 11, 2024

Conversation

leo-ware
Copy link
Contributor

@leo-ware leo-ware commented Apr 5, 2024

I wrote a couple of helper utilities to make it easier to use the code inside other Python code.

Key changes:

  • Added a Dataset.from_pandas method
  • Added a train method to IrtModel
  • Added an example notebook demonstrating how to use the new features
  • Tests for my code

I was trying to use this library for a personal project, but I had trouble understanding how to orchestrate the whole IrtModel/IrtTrainer/IrtConfig setup at first. Also, I needed to use data that was in memory rather than in a file for my usecase, which was tricky previously. So, I thought I'd write some methods to get around these issues.

The following code now works:

from py_irt.dataset import Dataset
from py_irt.models import OneParamLog
import pandas as pd

df = pd.DataFrame({
    'subject_id': ["joe", "sarah", "juan", "julia"],
    'item_1': [0, 1, 1, 1],
    'item_2': [0, 1, 0, 1],
    'item_3': [1, 0, 1, 0],
})
dataset = Dataset.from_pandas(df, subject_column="subject_id", item_columns=["item_1", "item_2", "item_3"])

trainer = OneParamLog.train(data)
print(trainer.irt_model.export())

@jplalor jplalor merged commit 39147ba into nd-ball:master Apr 11, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants