2014-06-25 2 views
0

내가이 오류를 얻을 내 데이터 파일을 읽는되지 않습니다LensKit : LensKit 데모 내가 LensKit 데모 프로그램을 실행하면

[main] ERROR org.grouplens.lenskit.data.dao.DelimitedTextRatingCursor - C:\Users\sean\Desktop\ml-100k\u - Copy.data:4: invalid input, skipping line

을 내가 보는 해달라고하지만 그것은 단지이 줄을 보유하도록 내가 ML을 설정 100,000 데이터를 재 이것은 영향을 얼마나 :

public class HelloLenskit implements Runnable { 
public static void main(String[] args) { 
    HelloLenskit hello = new HelloLenskit(args); 
    try { 
     hello.run(); 
    } catch (RuntimeException e) { 
     System.err.println(e.getMessage()); 
     System.exit(1); 
    } 
} 

private String delimiter = "\t"; 
private File inputFile = new File("C:\\Users\\sean\\Desktop\\ml-100k\\u - Copy.data"); 
private List<Long> users; 

public HelloLenskit(String[] args) { 
    int nextArg = 0; 
    boolean done = false; 
    while (!done && nextArg < args.length) { 
     String arg = args[nextArg]; 
     if (arg.equals("-e")) { 
      delimiter = args[nextArg + 1]; 
      nextArg += 2; 
     } else if (arg.startsWith("-")) { 
      throw new RuntimeException("unknown option: " + arg); 
     } else { 
      inputFile = new File(arg); 
      nextArg += 1; 
      done = true; 
     } 
    } 
    users = new ArrayList<Long>(args.length - nextArg); 
    for (; nextArg < args.length; nextArg++) { 
     users.add(Long.parseLong(args[nextArg])); 
    } 
} 

public void run() { 
    // We first need to configure the data access. 
    // We will use a simple delimited file; you can use something else like 
    // a database (see JDBCRatingDAO). 
    EventDAO base = new SimpleFileRatingDAO(inputFile, "\t"); 
    // Reading directly from CSV files is slow, so we'll cache it in memory. 
    // You can use SoftFactory here to allow ratings to be expunged and re-read 
    // as memory limits demand. If you're using a database, just use it directly. 
    EventDAO dao = new EventCollectionDAO(Cursors.makeList(base.streamEvents())); 

    // Second step is to create the LensKit configuration... 
    LenskitConfiguration config = new LenskitConfiguration(); 
    // ... configure the data source 
    config.bind(EventDAO.class).to(dao); 
    // ... and configure the item scorer. The bind and set methods 
    // are what you use to do that. Here, we want an item-item scorer. 
    config.bind(ItemScorer.class) 
      .to(ItemItemScorer.class); 

    // let's use personalized mean rating as the baseline/fallback predictor. 
    // 2-step process: 
    // First, use the user mean rating as the baseline scorer 
    config.bind(BaselineScorer.class, ItemScorer.class) 
      .to(UserMeanItemScorer.class); 
    // Second, use the item mean rating as the base for user means 
    config.bind(UserMeanBaseline.class, ItemScorer.class) 
      .to(ItemMeanRatingItemScorer.class); 
    // and normalize ratings by baseline prior to computing similarities 
    config.bind(UserVectorNormalizer.class) 
      .to(BaselineSubtractingUserVectorNormalizer.class); 

    // There are more parameters, roles, and components that can be set. See the 
    // JavaDoc for each recommender algorithm for more information. 

    // Now that we have a factory, build a recommender from the configuration 
    // and data source. This will compute the similarity matrix and return a recommender 
    // that uses it. 
    Recommender rec = null; 
    try { 
     rec = LenskitRecommender.build(config); 
    } catch (RecommenderBuildException e) { 
     throw new RuntimeException("recommender build failed", e); 
    } 

    // we want to recommend items 
    ItemRecommender irec = rec.getItemRecommender(); 
    assert irec != null; // not null because we configured one 
    // for users 
    for (long user: users) { 
     // get 10 recommendation for the user 
     List<ScoredId> recs = irec.recommend(user, 10); 
     System.out.format("Recommendations for %d:\n", user); 
     for (ScoredId item: recs) { 
      System.out.format("\t%d\n", item.getId()); 
     } 
    } 
} 
} 

난 정말이에 손실 오전 : 여기

196 242 3 881250949 
186 302 3 891717742 
22 377 1 878887116 
244 

내가 너무 사용하고있는 코드입니다 하나는 도움이 될 것입니다. 시간 내 줘서 고마워.

답변

1

입력 파일의 마지막 줄에는 하나의 필드 만 포함됩니다. 각 입력 파일 행에는 3 또는 4 개의 필드가 있어야합니다.