List of usage examples for org.apache.mahout.cf.taste.common TasteException TasteException
public TasteException(String message, Throwable cause)
From source file:com.recsys.svd.CustomSVDRecommender.java
License:Apache License
/** * Create an SVDRecommender using a persistent store to cache * factorizations. A factorization is loaded from the store if present, * otherwise a new factorization is computed and saved in the store. * * The {@link #refresh(java.util.Collection) refresh} method recomputes the * factorization and overwrites the store. * * @param dataModel/*from w ww . j av a 2 s. c o m*/ * @param factorizer * @param candidateItemsStrategy * @param persistenceStrategy * * @throws TasteException */ public CustomSVDRecommender(DataModel dataModel, Factorizer factorizer, CandidateItemsStrategy candidateItemsStrategy, PersistenceStrategy persistenceStrategy) throws TasteException { super(dataModel, candidateItemsStrategy); this.factorizer = Preconditions.checkNotNull(factorizer); this.persistenceStrategy = Preconditions.checkNotNull(persistenceStrategy); try { factorization = persistenceStrategy.load(); } catch (IOException e) { throw new TasteException("Error loading factorization", e); } if (factorization == null) { train(); } refreshHelper = new RefreshHelper(new Callable<Object>() { @Override public Object call() throws TasteException { train(); return null; } }); refreshHelper.addDependency(getDataModel()); refreshHelper.addDependency(factorizer); }
From source file:com.recsys.svd.CustomSVDRecommender.java
License:Apache License
private void train() throws TasteException { factorization = factorizer.factorize(); try {//from w ww. ja v a 2 s . c o m persistenceStrategy.maybePersist(factorization); } catch (IOException e) { throw new TasteException("Error persisting factorization", e); } }
From source file:org.plista.kornakapi.core.recommender.FoldingFactorizationBasedRecommender.java
License:Apache License
public FoldingFactorizationBasedRecommender(DataModel dataModel, CandidateItemsStrategy candidateItemsStrategy, PersistenceStrategy persistenceStrategy, int numEstimationThreads) throws TasteException { super(dataModel, candidateItemsStrategy); this.persistenceStrategy = Preconditions.checkNotNull(persistenceStrategy); try {// ww w. j av a2 s. c om Factorization factorization = persistenceStrategy.load(); Preconditions.checkNotNull(factorization, "PersistenceStrategy must provide an initial factorization"); foldingFactorization = new FoldingFactorization(factorization); } catch (IOException e) { throw new TasteException("Error loading factorization", e); } this.numEstimationThreads = numEstimationThreads; refreshHelper = new RefreshHelper(new Callable<Object>() { @Override public Object call() throws TasteException { reloadFactorization(); return null; } }); refreshHelper.addDependency(getDataModel()); refreshHelper.addDependency(candidateItemsStrategy); }
From source file:org.plista.kornakapi.core.recommender.FoldingFactorizationBasedRecommender.java
License:Apache License
private void reloadFactorization() throws TasteException { try {/* w w w . ja v a 2 s. co m*/ Factorization factorization = Preconditions.checkNotNull(persistenceStrategy.load()); foldingFactorization = new FoldingFactorization(factorization); } catch (IOException e) { throw new TasteException("Error reloading factorization", e); } }
From source file:org.zaizi.mahout.alfresco.datamodel.MetaversantDataModelImpl.java
License:Open Source License
private ResultSet executeQuery(SearchParameters params) throws TasteException { try {/*from w w w .j a va2 s . c o m*/ return ZaiziAlfrescoServiceUtil.getSearchService().query(params); } catch (AlfrescoRuntimeException are) { throw new TasteException("Error executing query :" + are, are); } }
From source file:recommender.CustomRecommender.java
/** * Create a custom SVDRecommender using a persistent store to cache * factorizations. A factorization is loaded from the store if present, * otherwise a new factorization is computed and saved in the store. * * The {@link #refresh(java.util.Collection) refresh} method recomputes the * factorization and overwrites the store. * * @param dataModel//from ww w. jav a 2s . c o m * @param factorizer * @param candidateItemsStrategy * @param persistenceStrategy * * @throws TasteException */ public CustomRecommender(DataModel dataModel, Factorizer factorizer, CandidateItemsStrategy candidateItemsStrategy, PersistenceStrategy persistenceStrategy) throws TasteException { super(dataModel, candidateItemsStrategy); this.factorizer = Preconditions.checkNotNull(factorizer); this.persistenceStrategy = Preconditions.checkNotNull(persistenceStrategy); try { factorization = persistenceStrategy.load(); } catch (IOException e) { throw new TasteException("Error loading factorization", e); } if (factorization == null) { train(); } refreshHelper = new RefreshHelper(new Callable<Object>() { @Override public Object call() throws TasteException { train(); return null; } }); refreshHelper.addDependency(getDataModel()); refreshHelper.addDependency(factorizer); refreshHelper.addDependency(candidateItemsStrategy); }
From source file:recommender.MyRecommender.java
/** * Create a custom SVDRecommender using a persistent store to cache * factorizations. A factorization is loaded from the store if present, * otherwise a new factorization is computed and saved in the store. * * The {@link #refresh(java.util.Collection) refresh} method recomputes the * factorization and overwrites the store. * * @param dataModel// www .j a v a2s . com * @param factorizer * @param candidateItemsStrategy * @param persistenceStrategy * * @throws TasteException */ public MyRecommender(DataModel dataModel, Factorizer factorizer, CandidateItemsStrategy candidateItemsStrategy, PersistenceStrategy persistenceStrategy) throws TasteException { super(dataModel, candidateItemsStrategy); this.factorizer = Preconditions.checkNotNull(factorizer); this.persistenceStrategy = Preconditions.checkNotNull(persistenceStrategy); try { factorization = persistenceStrategy.load(); } catch (IOException e) { throw new TasteException("Error loading factorization", e); } if (factorization == null) { train(); } refreshHelper = new RefreshHelper(new Callable<Object>() { @Override public Object call() throws TasteException { train(); return null; } }); refreshHelper.addDependency(getDataModel()); refreshHelper.addDependency(factorizer); refreshHelper.addDependency(candidateItemsStrategy); }