Skip to main content

VisCARS: Knowledge Graph-based Context-Aware Recommender System for Visualizations

Project description

VisCARS: Graph-Based Context-Aware Visualization Recommendation System

version

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

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

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

# 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

viscars-1.0.2-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file viscars-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: viscars-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 28.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.7

File hashes

Hashes for viscars-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fe7d4223f3d2f0fc7ca31653b4c6a11064455613d947ab1ec6de35785a02aa7f
MD5 26c3da71034c4769e0594b3d57a150f2
BLAKE2b-256 8136647b76497a2cb7496174675a0d4daca62948a9f3223cbf3b397b8ca3e823

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page