Skip to content

Create a BaseModel #17

@marcelcaraciolo

Description

@marcelcaraciolo

Create a BaseModel for DataHolders:

Following the patterns::

def UserIDs(self):
    '''
    Return all user IDs in the model, in order
    '''
    raise NotImplementedError("cannot instantiate Abstract Base Class")

def PreferencesFromUser(self,userID,orderByID=True):
    '''
    Return user's preferences, ordered by user ID (if orderByID is True) 
    or by the preference values (if orderById is False), as an array.
    '''
    raise NotImplementedError("cannot instantiate Abstract Base Class")

def ItemIDsFromUser(self,userID):
    '''
    Return IDs of items user expresses a preference for 
    '''
    raise NotImplementedError("cannot instantiate Abstract Base Class")

def ItemIDs(self):
    '''
    Return a iterator of all item IDs in the model, in order
    '''
    raise NotImplementedError("cannot instantiate Abstract Base Class")

def PreferencesForItem(self,itemID,orderByID=True):
    '''
    Return all existing Preferences expressed for that item, 
    ordered by user ID (if orderByID is True) or by the preference values 
    (if orderById is False), as an array.
    '''
    raise NotImplementedError("cannot instantiate Abstract Base Class")

def PreferenceValue(self,userID,itemID):
    '''
    Retrieves the preference value for a single user and item.
    '''
    raise NotImplementedError("cannot instantiate Abstract Base Class")

def PreferenceTime(self,userID,itemID):
    '''
    Retrieves the time at which a preference value from a user and item was set, if known.
    Time is expressed in the usual way, as a number of milliseconds since the epoch.
    '''
    raise NotImplementedError("cannot instantiate Abstract Base Class")

def NumUsers(self):
    '''
    Return total number of users known to the model.
    '''
    raise NotImplementedError("cannot instantiate Abstract Base Class")

def NumItems(self):
    '''
    Return total number of items known to the model.
    '''
    raise NotImplementedError("cannot instantiate Abstract Base Class")

def NumUsersWithPreferenceFor(self,*itemIDs):
    '''
    Return the number of users who have expressed a preference for all of the items
    '''
    raise NotImplementedError("cannot instantiate Abstract Base Class")

def setPreference(self,userID,itemID,value):
    '''
    Sets a particular preference (item plus rating) for a user.
    '''
    raise NotImplementedError("cannot instantiate Abstract Base Class")

def removePreference(self,userID, itemID):
    '''
    Removes a particular preference for a user.
    '''
    raise NotImplementedError("cannot instantiate Abstract Base Class")

def convertItemID2name(self, itemID):
    """Given item id number return item name"""
    raise NotImplementedError("cannot instantiate Abstract Base Class")

def convertUserID2name(self, userID):
    """Given user id number return user name"""
    raise NotImplementedError("cannot instantiate Abstract Base Class") 


def hasPreferenceValues(self):
    '''
    Return True if this implementation actually it is not a 'boolean' DataModel.
    Otherwise returns False.
    '''
    raise NotImplementedError("cannot instantiate Abstract Base Class")


def MaxPreference(self):
    '''
    Return the maximum preference value that is possible in the current problem domain being evaluated.
    For example, if the domain is movie ratings on a scale of 1 to 5, this should be 5. While  a recommender
    may estimate a preference value above 5.0, it isn't "fair" to consider that the system is actually
    suggesting an impossible rating of, say, 5.4 stars.
    In practice the application would cap this estimate to 5.0. Since evaluators evaluate
    the difference between estimated and actual value, this at least prevents this effect from unfairly
    penalizing a Recommender.
    '''
    raise NotImplementedError("cannot instantiate Abstract Base Class")


def MinPreference(self):
    '''
    Returns the minimum preference value that is possible in the current problem domain being evaluated
    '''
    raise NotImplementedError("cannot instantiate Abstract Base Class")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions