Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Learner

Learner is an api which allows you to create, edit and train your model in few lines.

Hierarchy

  • Learner

Index

Constructors

constructor

Properties

Optional MFC

dataBlock

dataBlock: DataBlock

embeddingOutputSize

embeddingOutputSize: number

itemsNum

itemsNum: number

Optional l2Labmda

l2Labmda?: number

learningRate

learningRate: number

lossFunc

lossFunc: string

model

model: LayersModel

modelToItemMap

modelToItemMap: Map<number, any>

modelToUserMap

modelToUserMap: Map<number, any>

optimizer

optimizer: Optimizer

optimizerName

optimizerName: string

Optional ratingRange

ratingRange?: number[]

usersNum

usersNum: number

Methods

addRating

  • addRating(userId: any, itemId: any, rating: any, train?: boolean): void | Promise<History>
  • To add a rating of a user on a certain item and add it to redis database

    Parameters

    • userId: any
    • itemId: any
    • rating: any
    • train: boolean = true

    Returns void | Promise<History>

addRatingSync

  • addRatingSync(userId: any, itemId: any, rating: any, train?: boolean): Promise<void>
  • Parameters

    • userId: any
    • itemId: any
    • rating: any
    • train: boolean = true

    Returns Promise<void>

fit

  • fit(epochs?: number): Promise<History>
  • To train the model in a number of epoches

    Parameters

    • epochs: number = 1

    Returns Promise<History>

load

  • load(path: string): Promise<Learner>
  • To load a pre-saved model

    if your data does not already have a DataBlock, only recommendItem method will work

    Parameters

    • path: string

    Returns Promise<Learner>

mostSimilarItems

  • mostSimilarItems(id: any, k?: number): number[]
  • To retrieve the k similar items of an item

    Parameters

    • id: any
    • k: number = 10

    Returns number[]

mostSimilarUsers

  • mostSimilarUsers(id: any, k?: number): string[]
  • To retrieve the k similar users of a user

    Parameters

    • id: any
    • k: number = 10

    Returns string[]

newItem

  • newItem(itemId: any): void
  • To add a new item embedding in the model. The embedding is generated based on the mean of the other item latent factors.

    Parameters

    • itemId: any

    Returns void

newUser

  • newUser(userId: any): void
  • To add a new user embedding in the model. The embedding is generated based on the mean of the other users latent factors.

    Parameters

    • userId: any

    Returns void

recommendItems

  • recommendItems(userId: any, k: number, alreadyWatched?: boolean): Promise<number[]>
  • To recommend k items for a user given their ID

    Parameters

    • userId: any
    • k: number
    • alreadyWatched: boolean = false

    Returns Promise<number[]>

save

  • save(path: string): Promise<SaveResult>
  • To save the architecture and the weights and id Maps of the model in a given path

    Parameters

    • path: string

    Returns Promise<SaveResult>

setOptimizer

  • setOptimizer(optimizerName: string): void
  • Setting an optimizer for leaner

    Parameters

    • optimizerName: string

    Returns void

viewed

  • viewed(userId: any, itemId: any): void
  • Use this when a user view an item but did not rate it, allowing pprec to not re-recommend this item

    Parameters

    • userId: any
    • itemId: any

    Returns void

Generated using TypeDoc