Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
72eb110
update UserKNN algorithm
EinfachAnass May 26, 2025
ec2bb97
updated the bias model
EinfachAnass May 26, 2025
5a956dd
updated ALS
EinfachAnass May 26, 2025
c9f08f8
updated the funksvd algorithm
EinfachAnass May 27, 2025
4fabb55
update ItemKNN
EinfachAnass May 27, 2025
1db221f
update the SVD algorithm
EinfachAnass May 27, 2025
7788bb7
updated lkauto.py, get_model_from_cs.py.
Catnatsuki May 28, 2025
5d3c451
Updated validation_split.py and test_validation_split.py to work with…
May 29, 2025
46bcfa6
Mainly updated get_default_configuration_space.py to use Datasets (or…
May 29, 2025
4f4a57a
updated lkauto.py, get_model_from_cs.py.
Catnatsuki Jun 1, 2025
7d62904
updated bayesian_optimization.py, explicit_evaler.py
Catnatsuki Jun 1, 2025
4b738a1
updated pruning.py
EinfachAnass Jun 2, 2025
50bcfe8
corrected a typo for interaction_table()
EinfachAnass Jun 2, 2025
0864783
Updated explicit_evaler.py to use Datasets instead of Dataframes
Jun 2, 2025
ab104ad
Updated explicit_evaler.py to use Datasets instead of Dataframes (now…
Jun 3, 2025
e1475a6
updated preprocessing.py
Catnatsuki Jun 3, 2025
b97cd4f
Merge branch 'update_lkauto' of https://github.com/ISG-Siegen/lenskit…
Catnatsuki Jun 3, 2025
8ffdc5d
Updated explicit_evaler.py and implicit_evaler.py to use Dataset for …
Jun 3, 2025
809d9d9
Updated ensemble_builder.py and greedy_ensemble_selection.py
Jun 3, 2025
209187e
Update in preprocessing.py, renames the columns. Only fixed for one d…
Jun 3, 2025
7e020bd
Updated implicit and explicit evaler. Saves with the correct metric-n…
Jun 11, 2025
0d31e21
Updated implicit and explicit evaler.
Jun 12, 2025
09d00f3
Updated filer.py so that validation_data can be saved to json
Jun 12, 2025
ede2c73
Removed print-statements
Jun 12, 2025
2c5845f
update the conda environement file
EinfachAnass Jun 13, 2025
6b26519
Updated get_default_configurations.py and get_model_from_cs.py and RE…
Jun 13, 2025
ca3cae2
test_get_default_configurations.py passes all
Jun 16, 2025
483c4ce
added the default value to the feature param
EinfachAnass Jun 17, 2025
64f3fb3
add feature as an instance variable to acces it during testing
EinfachAnass Jun 17, 2025
ae73e29
the testing for funk_svd works now
EinfachAnass Jun 17, 2025
3fd1efa
updated the depricated method in Configspace + test is OK
EinfachAnass Jun 17, 2025
b1829a2
testing for user knn is OK
EinfachAnass Jun 17, 2025
cb7b095
made the parameters accessible so we can access them for testing
EinfachAnass Jun 17, 2025
dcf95e1
deleted some not directly used parameters in Item_knn and made its pa…
EinfachAnass Jun 18, 2025
60030b6
update the numpy version
EinfachAnass Jun 18, 2025
4e0fde9
updated only the dependencies in pyproject.toml
EinfachAnass Jun 18, 2025
8f53978
update the install requires according to the environment.yml file ext…
EinfachAnass Jun 18, 2025
cd9c5fd
update als and test_als. Test is OK
EinfachAnass Jun 18, 2025
81f905b
made the parameter feature accessible for testing, added the default …
EinfachAnass Jun 18, 2025
ac670f1
changed model names in get_model_from_cs.py to reflect the new names …
Catnatsuki Jun 19, 2025
6b9d407
Fixed the test test_als.py, lower bound was 2 in the assertion but 5 …
Catnatsuki Jun 19, 2025
b30c388
Update tests.yml
Catnatsuki Jun 19, 2025
a14191a
Update tests.yml
Catnatsuki Jun 19, 2025
af600c8
Update tests.yml
Catnatsuki Jun 19, 2025
5165da2
updates setup.py and pyproject.toml to include numba as a requirement.
Catnatsuki Jun 19, 2025
fd91751
Merge branch 'update_lkauto' of https://github.com/ISG-Siegen/lenskit…
Catnatsuki Jun 19, 2025
9a4e8af
readded a variable that I had accidentally deleted in my last push.
Catnatsuki Jun 19, 2025
b904ff4
updated setup.py
EinfachAnass Jun 26, 2025
500833f
updated tox.ini
EinfachAnass Jun 26, 2025
d2941de
updated req_dev.txt
EinfachAnass Jun 26, 2025
4c1a60e
Updated the algo_lists for implicit and explicit feedback in get_defa…
Jun 26, 2025
f2d262e
Reverted the names in get_model_from_cs.py back to old names (i.e. It…
Jun 26, 2025
37e037e
Updated documentation comments and README.md
Jun 26, 2025
25d4fba
added a more newer and stable version for flake8
EinfachAnass Jun 27, 2025
fcbd4e2
updated pyproject.toml
EinfachAnass Jun 27, 2025
7819bf7
Fixed Flake8 warnings
Jun 27, 2025
a3844e1
Merge remote-tracking branch 'origin/update_lkauto' into update_lkauto
Jun 27, 2025
3a4c2ce
Updated the install process in the README.md
Jul 1, 2025
a712dbc
added matplotlib
EinfachAnass Jul 1, 2025
8a98c47
changed how to create a functioning environement with its dependencies
EinfachAnass Jul 1, 2025
9954f33
some minor updates regarding the installation
EinfachAnass Jul 2, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.8', '3.9']
python-version: ['3.12']

steps:
- uses: actions/checkout@v2
Expand Down
135 changes: 97 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,65 @@ LensKit-Auto is currently developed and tested only on Linux systems.

## Install

### Pip Install:
Lenskit-Auto requires at least Python 3.12.
You can set up your environment in two ways:
1. using the provided `environment.yml`.
2. Using `setup.py`

## 1. Using `environment.yml` (Conda)
This method creates a conda environment withh all dependencies including their versions.

```bash
pip install lkauto
# Create the environment
conda env create -f environment.yml

# Activate the environment
conda activate lkauto-env
```

### Conda Install
## 2. Using `setup.py` (pip)

This method works in any Python 3.12+ environment (e.g. conda, venv).

```bash
# Create and activate a new environment
conda create -n lkauto-env python=3.12
conda activate lkauto-env
# or use python -m venv venv_name && source venv_name/bin/activate

# Install the package and all dependencies
pip install .
```
# Note:
For now, after using one of these methods, you need to set the PYTHONPATH to your project root to run the scripts, since lkauto is not pip installable yet:

## Option A: Using PYTHONPATH
```bash
export PYTHONPATH=/path/to/your/lenskit-auto
```

## Option B: Using .env file (for VSCode)
create a `.env` file in your project root and add the following path inside it:
```bash
export PYTHONPATH=/path/to/your/lenskit-auto
```

## Getting the path:
clone our entire repo under a folder named `lenskit-auto`
```bash
git clone https://github.com/ISG-Siegen/lenskit-auto.git
```

navigate to the project directory:
```bash
cd lenskit-auto
```

checkout to the updated branch `update_lkauto`
```bash
git checkout update_lkauto
```

1. Create conda environment
2. Follow the Pip Install subchapter to install lenskit-auto in your conda environment

## Getting Started

Expand Down Expand Up @@ -72,13 +121,12 @@ Note: All application scenarios apply to Top-N ranking prediction and rating pre
of algorithms and/or different hyperparameter ranges for the provided dataset.

In order to take advantage of LensKit-Auto, a developer needs to read in a dataset.
The ``load_movielens()`` function can be used to load a MovieLens dataset for example.

```python
from lenskit.datasets import ML100K
from lenskit.data import load_movielens

ml100k = ML100K('path_to_file')
ratings = ml100k.ratings
ratings.name = 'ml_100k'
ml100k = load_movielens('path_to_file')
```

Furthermore, it is suggested, that we take advantage of the Filer to control the LensKit-Auto output
Expand All @@ -95,30 +143,32 @@ First, we need to split the data in a train and test split to evaluate our model
based on data rows or user data. For the rating prediction example we are splitting the data based on user data.

```python
import lenskit.crossfold as xf
from lenskit.batch import recommend
from lenskit import topn
from lenskit.splitting import crossfold_users, SampleN
from lenskit.metrics import RunAnalysis, NDCG
from lenskit.pipeline import topn_pipeline
from lkauto.lkauto import get_best_recommender_model

# User based data-split
for i, tp in enumerate(xf.partition_users(ratings, 1, xf.SampleN(5))):
train_split = tp.train.copy()
test_split = tp.test.copy()

# Fixme: INSERT SCENARIO CODE HERE

for split in crossfold_users(ml100k, 2, SampleN(5)):
train_split = split.train
test_split = split.test

# Fixme: INSERT SECENARIO CODE HERE

# create pipeline
pipeline = topn_pipeline(model)
# fit
model.fit(train_split)
# recommend
recs = recommend(algo=model, users=test_split['user'].unique(), n=5, n_jobs=1)
pipeline.train(train_split)
#recommend
recs = recommend(pipeline, test_split)

# initialize RecListAnalysis
rla = topn.RecListAnalysis()
# add precision metric
rla.add_metric(topn.ndcg)
# create run analysis
rla = RunAnalysis()
rla.add_metric(NDCG)
scores = rla.measure(recs, test_split)

# compute scores
scores = rla.compute(recs, test_split, include_missing=True)
print("Scores:\n", scores)
```

### Rating Prediction
Expand All @@ -128,17 +178,26 @@ based on data rows or user data. For the rating prediction example we are splitt
Top-N ranking predicion example showcases the data-split based on user data.

```python
from lenskit.metrics.predict import rmse
from lenskit.crossfold import sample_rows
from lenskit.metrics import RMSE, RunAnalysis
from lenskit.splitting import sample_records
from lenskit.pipeline import predict_pipeline
from lenskit.batch import predict
from lkauto.lkauto import get_best_prediction_model

train_split, test_split = sample_rows(ratings, None, 25000)
tt_split = sample_records(ml100k, 1000)
train_split = tt_split.train
test_split = tt_split.test

# Fixme: INSERT SCENARIO CODE HERE

model.fit(train_split)
predictions = model.predict(test_split)
root_mean_square_error = rmse(predictions, test_split['rating'])
pipeline = predict_pipeline(model)
pipeline.train(train_split)
recs = predict(pipeline, test_split)

rla = RunAnalysis()
rla.add_metric(RMSE)
scores = rla.measure(recs, test_split)
print("Scores:\n", scores)
```

#### Scenario 1
Expand Down Expand Up @@ -171,12 +230,12 @@ from lkauto.algorithms.item_knn import ItemItem

# initialize ItemItem ConfigurationSpace
cs = ItemItem.get_default_configspace()
cs.add_hyperparameters([Constant("algo", "ItemItem")])
cs.add(Constant(name="algo", value="ItemItem"))
# set a random seed for reproducible results
cs.seed(42)

# Provide the ItemItem ConfigurationSpace to the get_best_recommender_model function.
model, config = get_best_recommender_model(train=train_split, filer=filer, cs=cs)
# Provide the ItemItem ConfigurationSpace to the get_best_recommender_model function.
model, config = get_best_recommender_model(train_split, test_split, cs=cs)
```

Note: As described above, the *get_best_recommender_model()* is used for Top-N ranking prediction. If you want to find a
Expand All @@ -196,14 +255,14 @@ First, a parent-ConfigurationSpace needs to be initialized. All algorithm names
parent-ConfigurationSpace categorical *algo* hyperparameter.

```python
from ConfigSpace import ConfigurationSpace, Categorical
from ConfigSpace import ConfigurationSpace, CategoricalHyperparameter

# initialize ItemItem ConfigurationSpace
parent_cs = ConfigurationSpace()
# set a random seed for reproducible results
parent_cs.seed(42)
# add algorithm names as a constant
parent_cs.add_hyperparameters([Categorical("algo", ["ItemItem", "UserUser"])])
parent_cs.add([CategoricalHyperparameter("algo", ["ItemItem", "UserUser"])])
```

Afterward, we need to build the *ItemItem* and *UserUser* sub-ConfigurationSpace.
Expand Down Expand Up @@ -238,7 +297,7 @@ min_sim = Float('min_sim', bounds=(0, 0.1), default=0)

# Then, we initialize the sub-ConfigurationSpace and add the hyperparameters to it
user_user_cs = ConfigurationSpace()
user_user_cs.add_hyperparameters([nnbrs, min_nbrs, min_sim])
user_user_cs.add([nnbrs, min_nbrs, min_sim])

# Last, we add the user_user_cs to the parent-ConfigurationSpace

Expand Down
Loading