コード例 #1
0
        public static List<Movie> GetRecommendations(List<Movie> all, Dictionary<int, int> newRanks, List<Tuple<int, int, float>> oldRanks)
        {
            int newUserId = 0;
            Ratings ratings = new Ratings();

            foreach (var r in oldRanks)
            {
                ratings.Add(r.Item1, r.Item2, r.Item3);
                if (r.Item1 > newUserId) newUserId = r.Item1;
            }

            // this makes us sure that the new user has a unique id (bigger than all other)
            newUserId = newUserId + 1;

            foreach (var k in newRanks)
            {
                ratings.Add(newUserId, k.Key, (float)k.Value);
            }

            var engine = new BiPolarSlopeOne();

            // different algorithm:
            // var engine = new UserItemBaseline();

            engine.Ratings = ratings;

            engine.Train(); // warning: this could take some time!

            return all.Select(m =>
                                {
                                    m.Rank = engine.Predict(newUserId, m.Id); // do the prediction!
                                    return m;
                                }).ToList();
        }
コード例 #2
0
ファイル: md_docter_DA.cs プロジェクト: lehprject/sfjyDMS
 public List<md_docter> GetDoctorByIds(List<string> ids)
 {
     string id = string.Join(",", ids.Select(t => t));
     string sql = @"SELECT *
                     FROM md_docter
                     where FIND_IN_SET(pkid,@ids)";
     List<md_docter> resultlist = sqlHelper.ExecuteObjects<md_docter>(sql, new MySqlParameter("ids", id));
     return resultlist;
 }
コード例 #3
0
 public async Task<List<TestNodeAssembly>> SelectTests(List<string> testAssemblies = null)
 {
     var testsRootNode = await _testsTask;
     testsRootNode.IsIncluded = true;
     if(testAssemblies != null)
     {
         return testsRootNode.TestNodeAssemblies.Where(a => 
             testAssemblies.Select(Path.GetFileNameWithoutExtension).Contains(a.Name)).ToList();
     }
     else
     {
         return testsRootNode.TestNodeAssemblies.ToList();
     }
 }
コード例 #4
0
        public async Task<List<TestNodeAssembly>> SelectTests(List<string> testAssemblies = null)
        {
            var finder = new CoveringTestsFinder();
            List<CciModuleSource> modules = (await _assembliesTask)
                .Where(a => testAssemblies == null || testAssemblies.Select(Path.GetFileNameWithoutExtension)
                .Contains(a.Module.Name)).ToList();
            var coveringTask = finder.FindCoveringTests(modules, _matcher);

            var result = await TupleExtensions.WhenAll(Tuple.Create(coveringTask, _testsTask));
            var coveringTests = result.Item1;
            var testsRootNode = result.Item2;

            SelectOnlyCoveredTests(testsRootNode, coveringTests);

            TreeUtils.ExpandLoneNodes(testsRootNode);

            return testsRootNode.TestNodeAssemblies.ToList();
        }
コード例 #5
0
 public List<promotion_coupons_detail> GetCouponsDetailByIds(List<int> ids)
 {
     string id = string.Join(",", ids.Select(t => t));
     string sql = @"SELECT *
                     FROM promotion_coupons_detail
                     where FIND_IN_SET(pkid,@ids)";
     List<promotion_coupons_detail> resultlist = sqlHelper.ExecuteObjects<promotion_coupons_detail>(sql, new MySqlParameter("ids", id));
     return resultlist;
 }
コード例 #6
0
ファイル: UsuarioService.cs プロジェクト: TiagoSoczek/BSI-ATM
 private List<UsuarioDto> ToDto(List<Usuario> usuarios)
 {
     return usuarios.Select(u => new UsuarioDto {Login = u.Login, Saldo = u.Saldo}).ToList();
 }
コード例 #7
0
 private void SelectMonth()
 {
     DateTime now = new DateTime(int.Parse(this.YearDropDownList.SelectedValue), 1, 1);
     DateTime startMonth = new DateTime(now.Year, 1, 1);
     List<DateTime> months = new List<DateTime>(12);
     for (int i = 0; i < 12; i++)
     {
         months.Add(startMonth.AddMonths(i));
     }
     this.MonthDropDownList.DataSource = months.Select(m => new { MonthText = m.ToString("MMMM"), m.Month });
     this.MonthDropDownList.DataBind();
     this.SelectDay();
 }
コード例 #8
0
        private int[] PerformRandomFlight(int[] xi, double alfa)
        {
            int[] result = new int[n];
            xi.CopyTo(result, 0);

            if(alfa < 0 || alfa >= n ) throw new Exception("Zla alfa");
            var rand = new Random();

            int nrOfElementsToShuffle = (int) (alfa*rand.NextDouble());

            //choosing elements to be shuffled
            var positionsToShuffle = new List<int>();
            var needed = nrOfElementsToShuffle;
            var available = n;

            while (positionsToShuffle.Count < nrOfElementsToShuffle) {
               if( rand.NextDouble() < ((double)needed / available) )
               {
                  positionsToShuffle.Add(xi[available - 1]);
                  needed--;
               }
               available--;
            }

            //CHANGEME
            //shuffling them
            var valuesLeft = positionsToShuffle.Select(i => xi[i]).ToList();

            int left = nrOfElementsToShuffle;
            foreach (int i in positionsToShuffle)
            {
                result[i] = valuesLeft[rand.Next(left)];
            //                valuesLeft.Remove(xi[i]);
                valuesLeft.Remove(result[i]);
                left--;
            }

            if(left != 0) throw new Exception("nie powinnno nic zostac!");

            return result;
        }