Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions resampling-texts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ Using only texts selected through LS sampling allows new models to be efficientl
<img src="figures/fig3.png" alt="fig3" style="width:90%">
</p>

### Prediction of Model's Performance (Figure4)

Using model coordinates from unique texts, we predict the average performance across six downstream tasks with ridge regression.
See [`code_for_prediction/`](./code_for_prediction/) for details.

<p align="center">
<img src="figures/fig4.png" alt="fig4" style="width:50%">
</p>

## 🦉 Misc.

Expand Down
226 changes: 226 additions & 0 deletions resampling-texts/code_for_prediction/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
### Generated by gibo (https://github.com/simonwhitaker/gibo)
### https://raw.github.com/github/gitignore/d0b80a469983a7beece8fa1f5c48a8242318b531/Global/Vim.gitignore

# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim
Sessionx.vim

# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~


### https://raw.github.com/github/gitignore/d0b80a469983a7beece8fa1f5c48a8242318b531/Python.gitignore

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/


### https://raw.github.com/github/gitignore/d0b80a469983a7beece8fa1f5c48a8242318b531/C++.gitignore

# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# Added manually
.DS_Store
output/
1 change: 1 addition & 0 deletions resampling-texts/code_for_prediction/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
59 changes: 59 additions & 0 deletions resampling-texts/code_for_prediction/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## Model Performance Prediction (Section 4.3 and Appendix F)

We use [`uv`](https://docs.astral.sh/uv/) for the experiment environment in this directory. See the official site for installation.

### Setup

With `uv` available, install the required packages:

```bash
$ uv sync
```

The experiments use [`../data/modeldata_1018.pkl`](../data/modeldata_1018.pkl) and [`../data/uniq-idx-weight/`](../data/uniq-idx-weight/). See [`../README.md`](../README.md) for details of these data.

### Data Preparation

Prepare training and prediction splits for ridge regression with `GroupKFold`:

```bash
$ uv run src/split_data.py
```

Five-fold splits with five seeds are saved to `output/split_data/groupkfold/`.

### Train and Predict with Ridge Regression

Train the ridge regression models and generate predictions (**This step takes about half a day !**) :

```bash
$ uv run src/train_and_pred.py
```

Predictions for each method (Uniform, KL, LS) are saved to `output/train_and_pred/groupkfold/`.

### Plot Figures

Draw Figure 4 from the predictions:

```bash
$ uv run src/figure4.py
```

Figure 4 is saved to `output/images/`.

<p align="center">
<img src="figures/fig4.png" alt="fig4" style="width:50%">
</p>

Draw Figure 6 from the predictions:

```bash
$ uv run src/figure6_and_table2.py
```

<p align="center">
<img src="figures/fig6.png" alt="fig6" style="width:90%">
</p>

Figure 6 is saved to `output/images/`. This script also saves the results for Table 2 to `output/summary/`.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions resampling-texts/code_for_prediction/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[project]
name = "code-for-prediction"
version = "0.1.0"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"numpy",
"pandas",
"scikit-learn",
"fire",
"matplotlib",
"tqdm",
"jinja2>=3.1.6",
]
Loading