Exemplo n.º 1
0
        public SVDRecommender(DataModel dataModel, Factorizer factorizer, CandidateItemsStrategy candidateItemsStrategy, PersistenceStrategy persistenceStrategy)
            : base(dataModel, candidateItemsStrategy)
        {
            Action refreshRunnable = null;

            this.factorizer          = factorizer;
            this.persistenceStrategy = persistenceStrategy;
            try
            {
                this.factorization = persistenceStrategy.load();
            }
            catch (IOException exception)
            {
                throw new TasteException("Error loading factorization", exception);
            }
            if (this.factorization == null)
            {
                this.train();
            }
            if (refreshRunnable == null)
            {
                refreshRunnable = () => this.train();
            }
            this.refreshHelper = new RefreshHelper(refreshRunnable);
            this.refreshHelper.addDependency(this.getDataModel());
            this.refreshHelper.addDependency(factorizer);
            this.refreshHelper.addDependency(candidateItemsStrategy);
        }