# VisCARS: Graph-Based Context-Aware Visualization Recommendation System
![version](https://img.shields.io/pypi/v/viscars)
## Installation
Create a virtual environment using `virtualenv` or `anaconda3`:
```
conda create -n myenv python=3.9
conda activate myenv
```
Install the latest version from PyPI in your environment:
```
pip install viscars
```
## Basic usage
Load the dataset
```python
from rdflib import Graph
graph_ = Graph()
graph_.parse('../data/protego/protego_ddashboard.ttl')
graph_.parse('../data/protego/protego_zplus.ttl')
graph_.parse('../data/protego/visualizations.ttl')
```
Initialize the two-stage recommendation pipeline
```python
from viscars.dao import ContentRecommenderDAO, VisualizationRecommenderDAO
from viscars.recommenders.cacf import ContextAwareCollaborativeFiltering
# Initialize Content Recommender (stage 1)
content_dao = ContentRecommenderDAO(graph_)
content_recommender = ContextAwareCollaborativeFiltering(content_dao, cbcf_w=0.5, ubcf_w=0.5, verbose=False)
# Initialize Visualization Recommender (stage 2)
vis_dao = VisualizationRecommenderDAO(graph_)
visualization_recommender = ContextAwareCollaborativeFiltering(vis_dao, ubcf_w=1, verbose=False)
```
Run the pipeline for a user and context
```python
# user = 'https://dynamicdashboard.ilabt.imec.be/users/4' # Operator
user = 'https://dynamicdashboard.ilabt.imec.be/users/5' # Nurse
context = 'http://example.com/tx/patients/zplus_6' # Diabetes
content_recommendations = content_recommender.predict(user, context, k=5)
# Find cutoff for Multiple-View recommendation
# We recommend the top x items, where x is the average number of items rated by users in the context
ratings = content_dao.ratings[(content_dao.ratings['c_id'] == context)]
c = int(ratings.value_counts('u_id').mean())
visualization_recommendations = []
for recommendation in content_recommendations[:c]:
# Recommend visualizations
recommendations = visualization_recommender.predict(user, recommendation['itemId'], k=5)
visualization_recommendations.append({'propertyId': recommendation['itemId'], 'visualizationId': recommendations[0]['itemId']})
```
Example output
| propertyId | visualizationId |
|-----------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
| .../things/zplus_6.lifestyle/properties/enriched-call | .../things/visualizations/enriched-call |
| .../things/zplus_6.60%3A77%3A71%3A7D%3A93%3AD7%2Fservice0009/properties/org.dyamand.types.health.GlucoseLevel | .../things/visualizations/time-series-line-chart-with-time-range-selector |
| .../things/zplus_6.AQURA_10_10_145_9/properties/org.dyamand.aqura.AquraLocationState_Protego%20User | .../things/visualizations/scrolling-table |
## Citation
Raw data
{
"_id": null,
"home_page": "https://github.com/predict-idlab/VisCARS",
"name": "VisCARS",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9,<4.0",
"maintainer_email": "",
"keywords": "recommender system,visualizations,context-aware",
"author": "Pieter Moens",
"author_email": "pieter.moens@ugent.be",
"download_url": "",
"platform": null,
"description": "# VisCARS: Graph-Based Context-Aware Visualization Recommendation System\n\n![version](https://img.shields.io/pypi/v/viscars)\n\n## Installation\n\nCreate a virtual environment using `virtualenv` or `anaconda3`:\n```\nconda create -n myenv python=3.9\nconda activate myenv\n```\n\nInstall the latest version from PyPI in your environment:\n```\npip install viscars\n```\n\n## Basic usage\n\nLoad the dataset\n```python\nfrom rdflib import Graph\n\ngraph_ = Graph()\ngraph_.parse('../data/protego/protego_ddashboard.ttl')\ngraph_.parse('../data/protego/protego_zplus.ttl')\ngraph_.parse('../data/protego/visualizations.ttl')\n```\n\nInitialize the two-stage recommendation pipeline\n```python\nfrom viscars.dao import ContentRecommenderDAO, VisualizationRecommenderDAO\nfrom viscars.recommenders.cacf import ContextAwareCollaborativeFiltering\n\n# Initialize Content Recommender (stage 1)\ncontent_dao = ContentRecommenderDAO(graph_)\ncontent_recommender = ContextAwareCollaborativeFiltering(content_dao, cbcf_w=0.5, ubcf_w=0.5, verbose=False)\n\n# Initialize Visualization Recommender (stage 2)\nvis_dao = VisualizationRecommenderDAO(graph_)\nvisualization_recommender = ContextAwareCollaborativeFiltering(vis_dao, ubcf_w=1, verbose=False)\n```\n\nRun the pipeline for a user and context\n```python\n# user = 'https://dynamicdashboard.ilabt.imec.be/users/4' # Operator\nuser = 'https://dynamicdashboard.ilabt.imec.be/users/5' # Nurse\n\ncontext = 'http://example.com/tx/patients/zplus_6' # Diabetes\n\ncontent_recommendations = content_recommender.predict(user, context, k=5)\n\n# Find cutoff for Multiple-View recommendation\n# We recommend the top x items, where x is the average number of items rated by users in the context\nratings = content_dao.ratings[(content_dao.ratings['c_id'] == context)]\nc = int(ratings.value_counts('u_id').mean())\n\nvisualization_recommendations = []\nfor recommendation in content_recommendations[:c]:\n # Recommend visualizations\n recommendations = visualization_recommender.predict(user, recommendation['itemId'], k=5)\n visualization_recommendations.append({'propertyId': recommendation['itemId'], 'visualizationId': recommendations[0]['itemId']})\n```\n\nExample output\n\n| propertyId | visualizationId |\n|-----------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|\n| .../things/zplus_6.lifestyle/properties/enriched-call | .../things/visualizations/enriched-call |\n| .../things/zplus_6.60%3A77%3A71%3A7D%3A93%3AD7%2Fservice0009/properties/org.dyamand.types.health.GlucoseLevel | .../things/visualizations/time-series-line-chart-with-time-range-selector |\n| .../things/zplus_6.AQURA_10_10_145_9/properties/org.dyamand.aqura.AquraLocationState_Protego%20User | .../things/visualizations/scrolling-table |\n\n\n\n\n## Citation\n\n",
"bugtrack_url": null,
"license": "",
"summary": "VisCARS: Knowledge Graph-based Context-Aware Recommender System for Visualizations",
"version": "1.0.2",
"project_urls": {
"Documentation": "https://github.com/predict-idlab/VisCARS",
"Homepage": "https://github.com/predict-idlab/VisCARS",
"Repository": "https://github.com/predict-idlab/VisCARS"
},
"split_keywords": [
"recommender system",
"visualizations",
"context-aware"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8136647b76497a2cb7496174675a0d4daca62948a9f3223cbf3b397b8ca3e823",
"md5": "26c3da71034c4769e0594b3d57a150f2",
"sha256": "fe7d4223f3d2f0fc7ca31653b4c6a11064455613d947ab1ec6de35785a02aa7f"
},
"downloads": -1,
"filename": "viscars-1.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "26c3da71034c4769e0594b3d57a150f2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4.0",
"size": 28733,
"upload_time": "2024-02-12T15:57:18",
"upload_time_iso_8601": "2024-02-12T15:57:18.911100Z",
"url": "https://files.pythonhosted.org/packages/81/36/647b76497a2cb7496174675a0d4daca62948a9f3223cbf3b397b8ca3e823/viscars-1.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-12 15:57:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "predict-idlab",
"github_project": "VisCARS",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "viscars"
}