public MovieTweetingLibSvmFeatureBuilder(MovieTweetingsDataContainer container)
     : base()
 {
     _container        = container;
     _maxFollowerCount = _container.Tweets.Values.Max(t => t.FollowersCount);
     _maxFriendCount   = _container.Tweets.Values.Max(t => t.FriendsCount);
 }
 public MovieTweetingLibSvmFeatureBuilder(MovieTweetingsDataContainer container)
     : base()
 {
     _container = container;
     _maxFollowerCount = _container.Tweets.Values.Max(t => t.FollowersCount);
     _maxFriendCount = _container.Tweets.Values.Max(t => t.FriendsCount);
 }
Exemple #3
0
        static void Run(string trainingSet, string testSet)
        {
            // step 1: dataset
            var container = new MovieTweetingsDataContainer();

            var reader = new MovieTweetingsReader(trainingSet, testSet);

            reader.LoadData(container);

            Console.WriteLine("Data container statistics:\n {0}", container.ToString());

            var dataset = new ItemRatingDataset(container);

            var featureBuilder = new MovieTweetingLibSvmFeatureBuilder(container);


            // svm parameters
            var svmParameters = new SvmParameter
            {
                SvmType     = SvmType.C_SVC,
                KernelType  = KernelType.Linear,
                CacheSize   = 128,
                C           = 1,
                Eps         = 1e-3,
                Shrinking   = true,
                Probability = false
            };

            // step 2: recommender

            var labelSelector = new Func <ItemRating, double>(ir =>
            {
                var t = container.Tweets[ir];
                return(((t.RetweetCount + t.FavoriteCount) > 0) ? 1.0 : 0.0);
            });

            var recommender = new LibSvmClassifier(svmParameters, featureBuilder, labelSelector);

            // step3: evaluation
            var ep = new EvaluationPipeline <ItemRating>(new EvalutationContext <ItemRating>(recommender, dataset));

            ep.Evaluators.Add(new WriteChallengeOutput(container, "test_output.dat"));

            ep.Run();
        }
Exemple #4
0
        static void Run(string trainingSet, string testSet)
        {
            // step 1: dataset
            var container = new MovieTweetingsDataContainer();

            var reader = new MovieTweetingsReader(trainingSet, testSet);
            reader.LoadData(container);

            Console.WriteLine("Data container statistics:\n {0}", container.ToString());

            var dataset = new ItemRatingDataset(container);

            var featureBuilder = new MovieTweetingLibSvmFeatureBuilder(container);

            // svm parameters
            var svmParameters = new SvmParameter
            {
                SvmType = SvmType.C_SVC,
                KernelType = KernelType.Linear,
                CacheSize = 128,
                C = 1,
                Eps = 1e-3,
                Shrinking = true,
                Probability = false
            };

            // step 2: recommender

            var labelSelector = new Func<ItemRating, double>(ir =>
            {
                var t = container.Tweets[ir];
                return ((t.RetweetCount + t.FavoriteCount) > 0) ? 1.0 : 0.0;
            });

            var recommender = new LibSvmClassifier(svmParameters, featureBuilder, labelSelector);

            // step3: evaluation
            var ep = new EvaluationPipeline<ItemRating>(new EvalutationContext<ItemRating>(recommender, dataset));
            ep.Evaluators.Add(new WriteChallengeOutput(container, "test_output.dat"));

            ep.Run();
        }
Exemple #5
0
 public WriteChallengeOutput(MovieTweetingsDataContainer container, string outputPath)
 {
     _container  = container;
     _outputFile = outputPath;
 }