A low-code recommendation engine generation tool
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
Amethyst is a low-code, easy to use, GPU-powered recommender engine generator based on PyTorch. It requires only three parameters to rank/predict best items for users and vice-versa
- User ID (unique identifier for each user)
- Item ID (unique identifier for each item)
- User-Item Ratings (user-item rating/interaction scores)
Since all the underlying data operations are being handled by Pandas, amethyst supports a wide variety of database/data storage formats like SQL, NoSQL, CSV, TSV, etc.
The resultant recommendation scores are also obtained as a Pandas Dataframe, which helps in a flexible integration with your application.
This is an example of how you can generate your own collaborative recommendation engine. To get a local copy up and running follow these simple example steps.
- Python>=3.7
- Clone the repo
git clone https://github.com/radioactive11/amethyst.git
- Create and activate virtual environment
python3 -m venv venv source venv/bin/activate
- Install the tool
python3 setup.py install
A recommendation engine can be generated in 4 easy steps:
- Import the data
- Select an algorithm
- Train the model
- Evaluate the model's performance
from amethyst.dataloader import split
df = pd.read_csv("./movielens100k.csv")
df_train, df_test = split.stratified_split(
df,
0.8,
user_col='userID',
item_col='itemID',
filter_col='item'
)
from amethyst.dataloader import dataset
df = pd.read_csv("movielens100k.csv")
# from Data Split
df_train, df_test = split.stratified_split(df)
train = dataset.Dataloader.dataloader(df_train.itertuples(index=False))
test = dataset.Dataloader.dataloader(df_test.itertuples(index=False))
from amethyst.models.bivaecf.bivaecf import BiVAECF
import torch
bivae = BiVAECF(
k=50,
encoder_structure=[100],
act_fn=["tanh"],
likelihood="pois",
n_epochs=500,
batch_size=256,
learning_rate=0.001,
seed=42,
use_gpu=torch.cuda.is_available(),
verbose=True
)
bivae.fit(train, test)
bivae.save("model.pkl")
from amethyst.models.ibpr.ibprcf import IBPR
import torch
ibpr = IBPR(
k=20,
max_iter=100,
alpha_=0.05,
lambda_=0.001,
batch_size=100,
trainable=True,
verbose=False,
init_params=None)
ibpr.fit(train, test)
ibpr.save("model.pkl")
from amethyst.models.predictions import rank
from amethyst.models.bivaecf.bivaecf import BiVAECF
bivae = BiVAECF(
k=50,
encoder_structure=[100],
act_fn=["tanh"],
likelihood="pois",
n_epochs=500,
batch_size=256,
learning_rate=0.001,
seed=42,
use_gpu=torch.cuda.is_available(),
verbose=True
)
bivae.load("mode.pkl")
predictions = rank(bivae, test, user_col='userID', item_col='itemID')
# predictions is a Pandas Dataframe
predictions.to_csv("predictions.csv", index=False)
from amethyst.models.predictions import rank
from amethyst.eval.eval_methods import map_at_k, precision_at_k, recall_k
bivae = BiVAECF(
k=50,
encoder_structure=[100],
act_fn=["tanh"],
likelihood="pois",
n_epochs=500,
batch_size=256,
learning_rate=0.001,
seed=42,
use_gpu=torch.cuda.is_available(),
verbose=True
)
bivae.load("mode.pkl")
predictions = rank(bivae, test, user_col='userID', item_col='itemID')
eval_map = map_at_k(test, predictions, k=10)
pk = precision_at_k(test, predictions, k=10)
rk = recall_k(test, predictions)
- [] Build API Wrapper
- [] Use Elastic Search to save recommendations
- [] Add more algorithms
- [] Add content-based recommendation generation
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Arijit Roy - @_radioactive11_ - roy.arijit2001@gmail.com
Project Link: https://github.com/radioactive11/amethyst