Package org.grouplens.lenskit

Examples of org.grouplens.lenskit.RecommenderBuildException


                logger.debug("graph went from {} to {} nodes",
                             recommenderGraph.getReachableNodes().size(),
                             graph.getReachableNodes().size());
            } catch (InjectionException e) {
                logger.error("Error encountered while pre-processing algorithm components for sharing", e);
                throw new RecommenderBuildException("Pre-processing of algorithm components for sharing failed.", e);
            }
        }
        recommender = new LenskitRecommender(graph);
        // pre-fetch the test DAO
        userEvents = dataSet.getTestData().getUserEventDAO();
View Full Code Here


        final File train;
        try {
            train = trainingFile(dataSet);
        } catch (IOException e) {
            throw new RecommenderBuildException("error preparing training file", e);
        }
        final File test;
        try {
            test = testFile(dataSet);
        } catch (IOException e) {
            throw new RecommenderBuildException("error preparing test file", e);
        }
        final File output = getFile("predictions.csv");
        List<String> args = Lists.transform(algorithm.getCommand(), new Function<String, String>() {
            @Nullable
            @Override
            public String apply(@Nullable String input) {
                if (input == null) {
                    throw new NullPointerException("command element");
                }
                String s = input.replace("{OUTPUT}", output.getAbsolutePath());
                s = s.replace("{TRAIN_DATA}", train.getAbsolutePath());
                s = s.replace("{TEST_DATA}", test.getAbsolutePath());
                return s;
            }
        });

        logger.info("running {}", StringUtils.join(args, " "));

        Process proc;
        try {
            proc = new ProcessBuilder().command(args)
                                       .directory(algorithm.getWorkDir())
                                       .start();
        } catch (IOException e) {
            throw new RecommenderBuildException("error creating process", e);
        }
        Thread listen = new LoggingStreamSlurper("external-algo", proc.getErrorStream(),
                                                 logger, "external: ");
        listen.run();

        int result = -1;
        boolean done = false;
        while (!done) {
            try {
                result = proc.waitFor();
                done = true;
            } catch (InterruptedException e) {
                logger.info("thread interrupted, killing subprocess");
                proc.destroy();
                throw new RecommenderBuildException("recommender build interrupted", e);
            }
        }

        if (result != 0) {
            logger.error("external command exited with status {}", result);
            throw new RecommenderBuildException("recommender exited with code " + result);
        }

        Long2ObjectMap<SparseVector> vectors;
        try {
            vectors = readPredictions(output);
        } catch (FileNotFoundException e) {
            logger.error("cannot find expected output file {}", output);
            throw new RecommenderBuildException("recommender produced no output", e);
        }

        userPredictions = vectors;

        userTrainingEvents = dataSet.getTrainingData().getUserEventDAO();
View Full Code Here

                    continue;
                }
                if (row.length < 3) {
                    logger.error("predictions line {}: invalid row {}", n,
                                 StringUtils.join(row, ","));
                    throw new RecommenderBuildException("invalid prediction row");
                }
                long uid = Long.parseLong(row[0]);
                long iid = Long.parseLong(row[1]);
                double pred = Double.parseDouble(row[2]);
                Long2DoubleMap user = data.get(uid);
View Full Code Here

        }
        RecommenderInstantiator inst;
        try {
            inst = RecommenderInstantiator.create(rgb.buildGraph());
        } catch (ResolutionException e) {
            throw new RecommenderBuildException("Cannot resolve recommender graph", e);
        }
        DAGNode<Component, Dependency> graph = inst.instantiate();

        graph = rewriteGraph(graph);
View Full Code Here

     */
    public DAGNode<Component,Dependency> instantiate() throws RecommenderBuildException {
        try {
            return replaceShareableNodes(NodeProcessors.instantiate(instantiator));
        } catch (InjectionException e) {
            throw new RecommenderBuildException("Recommender instantiation failed", e);
        }
    }
View Full Code Here

     */
    public DAGNode<Component,Dependency> simulate() throws RecommenderBuildException {
        try {
            return replaceShareableNodes(NodeProcessors.simulateInstantiation());
        } catch (InjectionException e) {
            throw new RecommenderBuildException("Simulated instantiation failed", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.grouplens.lenskit.RecommenderBuildException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.