Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/voitijaner/Movie-RSs-Master-Thesis-Submission-Voit
13 April 2026, 06:30:59 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
Revision dadcec2ae8e6965a5002afbaf7341d8ca19d0438 authored by voitijaner on 04 September 2020, 12:46:31 UTC, committed by GitHub on 04 September 2020, 12:46:31 UTC
Update README.md
1 parent 4ea0873
  • Files
  • Changes
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • dadcec2ae8e6965a5002afbaf7341d8ca19d0438
    No releases to show
  • 5a1679a
  • /
  • statistic_calculations.py
Raw File Download Save again
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
  • snapshot
origin badgerevision badge
swh:1:rev:dadcec2ae8e6965a5002afbaf7341d8ca19d0438
origin badgedirectory badge
swh:1:dir:5a1679a3579764cbd88c758be59c337e0f88a277
origin badgecontent badge
swh:1:cnt:df0a5678c07d4b11e9e968f3c42da0498ea36ffb
origin badgesnapshot badge
swh:1:snp:05209ae0637e958e50eeaa64344e5e782b08b1d2

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
  • snapshot
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tip revision: dadcec2ae8e6965a5002afbaf7341d8ca19d0438 authored by voitijaner on 04 September 2020, 12:46:31 UTC
Update README.md
Tip revision: dadcec2
statistic_calculations.py
import pandas as pd


"""The genre, year and production country specific genres can be found in the corresponding files."""

def loadMovieLenseMapping():
	"""Returns the movielensemapping.csv dataset"""
	return pd.read_csv('data/movielense/movielense_mapping/movielensmapping.csv', sep='\t', encoding='utf-8', usecols=[0,1,2], names=['id', 'name', 'dbpediaLink'])

def loadFinalMovieList():
    """Returns the final movie List, extracted from the language_mapping_list of the similarMovieExtraction file."""
    file = open('data/lang_versions/mapping_to_other_languages/lang_mapping_list_2016.pkl', 'rb')
    movie_mapping_list = pickle.load(file)
    return movie_mapping_list['english_version'].unique()

def loadMovieLenseRatings():
    """Returns MovieLense ratings dataset."""
    return pd.read_csv('data/movielense/ratings.dat', sep='::', usecols=[0,1,2], names=['user_id', 'movie_id', 'rating'], encoding="utf-8")

def calculateAndPrintSparsity():
    """Calculate and prints sparsity."""

    #Load Data
    ratings = loadMovieLenseRatings()
    movielenseMapping = loadMovieLenseMapping()
    movies = loadFinalMovieList()
    #Sparsity initial data set
    sparsity = 1 - len(ratings) / (len(ratings['user_id'].unique()) * len(ratings['movie_id'].unique()))
    print("Initial")
    print("Users: " + str(len(ratings['user_id'].unique())))
    print("Movies: " + str(len(ratings['movie_id'].unique())))
    print("Sparsity: " + str(sparsity))


    #Sparsity after movie selection
    movielenseMapping = movielenseMapping[movielenseMapping.dbpediaLink.isin(movies)]

    ratings = ratings[ratings.movie_id.isin(movielenseMapping['id'])]

    sparsity = 1 - len(ratings) / (len(ratings['user_id'].unique()) * len(ratings['movie_id'].unique()))

    print("After movie selection")
    print("Users: " + str(len(ratings['user_id'].unique())))
    print("Movies: " + str(len(ratings['movie_id'].unique())))
    print("Sparsity: " + str(sparsity))


    #Sparsity after preprocessing
    ratings['frequency'] = ratings['movie_id'].map(ratings['movie_id'].value_counts())

    ratings = ratings.sort_values(by=['frequency'], ascending=False)

    count = 0
    for item in ratings['movie_id'].unique():
        if count < len(ratings['movie_id'].unique())/100:
            ratings = ratings[ratings['movie_id'] != item]
        count += 1  
    ratings = ratings.groupby('user_id').filter(lambda x: len(x) >= 50)
    ratings = ratings.drop(['frequency'], axis=1)

    sparsity = 1 - len(ratings) / (len(ratings['user_id'].unique()) * len(ratings['movie_id'].unique()))

    print("After preprocessing")
    print("Users: " + str(len(ratings['user_id'].unique())))
    print("Movies: " + str(len(ratings['movie_id'].unique())))
    print("Sparsity: " + str(sparsity))


    movies_not_in_ratings = movielenseMapping[~movielenseMapping.id.isin(ratings['movie_id'])]
    print("Movies not in ratings")
    print(movies_not_in_ratings['id'])


calculateAndPrintSparsity()
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API