Пример #1
0
        public List <ClssRules> GetRulesXetTuyen(double sup, double con)
        {
            //double minSupport = Double.Parse(formCollection["MinSupport"]);
            //double minConfidence = Double.Parse(formCollection["MinConfidence"]);
            WebDbContext dbContext    = new WebDbContext();
            var          dataListView = (from HoSoXetTuyens in dbContext.HoSoXetTuyens
                                         from Tinhs in dbContext.Tinhs
                                         where
                                         HoSoXetTuyens.TruongTHPT.MaTinh == Tinhs.MaTinh
                                         select new
            {
                HoSoXetTuyens.CMDN,
                HoSoXetTuyens.TruongTHPT.TenTruong,
                Tinhs.TenTinh,
                HinhThucXetTuyen = (bool?)HoSoXetTuyens.DiemXetTuyen.HinhThucXetTuyen
            }).ToList();
            string result = "";

            foreach (var item in dataListView)
            {
                db.Add(new clssItemSet()
                {
                    (item.HinhThucXetTuyen == true ? "Thi tuyển" : "Học bạ"),
                    item.TenTinh
                });
            }

            clssItemSet        uniqueItems = db.GetUniqueItems();
            ClssItemCollection L           = clssApriori.DoApriori(db, sup);
            List <ClssRules>   allRules    = clssApriori.Mine(db, L, con);

            result = "\n" + allRules.Count + " rules \n";

            return(allRules);
        }
Пример #2
0
        //********************************************

        #region Ham lay ra danh sach cac luat:Khoa =>Mon cai thien

        public List <ClssRules> LuatCaiThien(double sup, double con)
        {
            //double minSupport = Double.Parse(formCollection["MinSupport"]);
            //double minConfidence = Double.Parse(formCollection["MinConfidence"]);
            WebDbContext dbContext    = new WebDbContext();
            var          dataListView = (from a in (
                                             (from dcthk in dbContext.DiemCTHKys
                                              from sv in dbContext.SinhViens
                                              where
                                              dcthk.MSSV == sv.MSSV
                                              select new
            {
                dcthk.MaMon,
                dcthk.MSSV,
                dcthk.DiemTKHe4,
                dcthk.MonHoc.TenMon,
                sv.Lop.Khoa.TenKhoa
            }))
                                         group a by new
            {
                a.MaMon,
                a.MSSV,
                a.TenMon,
                a.TenKhoa
            } into g
                                         where g.Count() > 1
                                         select new
            {
                g.Key.TenMon,
                g.Key.TenKhoa
            }).ToList();
            string result = "";

            foreach (var item in dataListView)
            {
                db.Add(new clssItemSet()
                {
                    item.TenMon,
                    item.TenKhoa
                });
            }

            clssItemSet        uniqueItems = db.GetUniqueItems();
            ClssItemCollection L           = clssApriori.DoApriori(db, sup);
            List <ClssRules>   allRules    = clssApriori.Mine(db, L, con);

            result = "\n" + allRules.Count + " rules \n";

            return(allRules);
        }
Пример #3
0
        public List <ClssRules> GetRulesHocCaiThien(double sup, double con)
        {
            WebDbContext dbContext    = new WebDbContext();
            var          dataListView = ((from a in (
                                              (from dcthk in dbContext.DiemCTHKys
                                               where
                                               dcthk.DiemTKHe10 >= dcthk.MonHoc.DiemDat
                                               select new
            {
                dcthk.MSSV,
                dcthk.MonHoc.MaMon,
                dcthk.DiemTKHe10,
                dcthk.MonHoc.TenMon,
                dcthk.ID_HocKi
            }))
                                          group a by new
            {
                a.MSSV,
                a.MaMon,
                a.TenMon
            } into g
                                          where (g.Max(p => p.DiemTKHe10) - g.Min(p => p.DiemTKHe10)) > 0
                                          select new
            {
                g.Key.MSSV,
                g.Key.MaMon,
                g.Key.TenMon,
                chechlech = (double?)(g.Max(p => p.DiemTKHe10) - g.Min(p => p.DiemTKHe10))
            })).ToList();
            string result = "";

            foreach (var item in dataListView)
            {
                db.Add(new clssItemSet()
                {
                    item.TenMon,
                    item.chechlech.ToString()
                });
            }

            clssItemSet        uniqueItems = db.GetUniqueItems();
            ClssItemCollection L           = clssApriori.DoApriori(db, sup);
            List <ClssRules>   allRules    = clssApriori.Mine(db, L, con);

            result = "\n" + allRules.Count + " rules \n";

            return(allRules);
        }
Пример #4
0
        public List <ClssRules> GetRulesHocVuot(double sup, double con)
        {
            WebDbContext dbContext    = new WebDbContext();
            var          dataListView = ((from CTDT in dbContext.ChuongTrinhDaoTaos
                                          from dcthk in dbContext.DiemCTHKys
                                          where
                                          !
                                          (from ct in dbContext.ChuongTrinhDaoTaos
                                           where
                                           ct.MaKhoa == dcthk.DiemHocKy.SinhVien.Lop.ChuyenNganh.Khoa.MaKhoa &&
                                           ct.ID_HocKi == dcthk.ID_HocKi
                                           select new
            {
                ct.MaMon
            }).Contains(new { MaMon = dcthk.MaMon })
                                          select new
            {
                dcthk.MaMon,
                dcthk.DiemHocKy.SinhVien.MSSV,
                dcthk.DiemTKHe10,
                dcthk.MonHoc.TenMon,
                dcthk.ID_HocKi
            })).Distinct().ToList();
            string result = "";

            foreach (var item in dataListView)
            {
                db.Add(new clssItemSet()
                {
                    item.TenMon,
                    item.DiemTKHe10.ToString()
                });
            }

            clssItemSet        uniqueItems = db.GetUniqueItems();
            ClssItemCollection L           = clssApriori.DoApriori(db, sup);
            List <ClssRules>   allRules    = clssApriori.Mine(db, L, con);

            result = "\n" + allRules.Count + " rules \n";

            return(allRules);
        }
Пример #5
0
        public List <ClssRules> GetRulesXetTuyen(double sup, double con)
        {
            WebDbContext dbContext    = new WebDbContext();
            var          dataListView = (from CTDT in dbContext.ChuongTrinhDaoTaos
                                         from dcthk in dbContext.DiemCTHKys
                                         from sv in dbContext.SinhViens
                                         from dhk in dbContext.DiemHocKys
                                         where dcthk.MSSV == sv.MSSV
                                         &&
                                         !(from ct in dbContext.ChuongTrinhDaoTaos
                                           where sv.Lop.Khoa.MaKhoa == ct.MaKhoa && ct.ID_HocKi == dcthk.ID_HocKi
                                           select new
            {
                ct.MaMon
            }).Contains(new { MaMon = dcthk.MaMon })
                                         select new
            {
                sv.Lop.Khoa.TenKhoa,
                dcthk.MonHoc.TenMon,
                sv.MSSV
            }).Distinct().ToList();
            string result = "";

            foreach (var item in dataListView)
            {
                db.Add(new clssItemSet()
                {
                    item.TenMon,
                    item.TenKhoa
                });
            }

            clssItemSet        uniqueItems = db.GetUniqueItems();
            ClssItemCollection L           = clssApriori.DoApriori(db, sup);
            List <ClssRules>   allRules    = clssApriori.Mine(db, L, con);

            result = "\n" + allRules.Count + " rules \n";

            return(allRules);
        }
        //*****************

        #region Ham lay ra ds cac luat :Thi Tuyen: Nganh=> diem xet tuyen

        public List <ClssRules> ThiTuyen(double sup, double con)
        {
            //double minSupport = Double.Parse(formCollection["MinSupport"]);
            //double minConfidence = Double.Parse(formCollection["MinConfidence"]);
            WebDbContext dbContext    = new WebDbContext();
            var          dataListView = (from ds in dbContext.DSNguyenVongs
                                         where
                                         ds.HoSoXetTuyen.DiemXetTuyen.HinhThucXetTuyen == false &&
                                         ds.HoSoXetTuyen.TinhTrangTrungTuyen == 1
                                         select new
            {
                ds.NganhTheoBo.TeNganh,
                TongDiem = (ds.DiemTong < 30) ? (ds.DiemTong > 27) ? "[28,29,30]"
                                     : (ds.DiemTong > 24) ? "[25,26,27]"
                                    : (ds.DiemTong > 21) ? "[22,23,24]"
                                    : (ds.DiemTong > 18) ? "[19,20,21]"
                                    : (ds.DiemTong > 15) ? "[16,17,18]"
                                    : "[0..12,13,14,15]" : ""
            }).ToList();
            string result = "";

            foreach (var item in dataListView)
            {
                db.Add(new clssItemSet()
                {
                    item.TeNganh,
                    Convert.ToString(item.TongDiem)
                });
            }

            clssItemSet        uniqueItems = db.GetUniqueItems();
            ClssItemCollection L           = clssApriori.DoApriori(db, sup);
            List <ClssRules>   allRules    = clssApriori.Mine(db, L, con);

            result = "\n" + allRules.Count + " rules \n";

            return(allRules);
        }
Пример #7
0
        public List <ClssRules> GetRulesNhapHocDau_KhuVuc(double sup, double con)
        {
            //double minSupport = Double.Parse(formCollection["MinSupport"]);
            //double minConfidence = Double.Parse(formCollection["MinConfidence"]);
            WebDbContext dbContext    = new WebDbContext();
            var          dataListView = ((
                                             from HoSoXetTuyens in dbContext.HoSoXetTuyens
                                             from Tinhs in dbContext.Tinhs
                                             from DSNguyenVongs in dbContext.DSNguyenVongs
                                             from NganhTheoBo in dbContext.NganhTheoBos
                                             where
                                             HoSoXetTuyens.TruongTHPT.MaTinh == Tinhs.MaTinh &&
                                             //HoSoXetTuyens.TinhTrangTrungTuyen == 1 &&
                                             //thinh update API
                                             HoSoXetTuyens.MaHoSo == DSNguyenVongs.MaHoSo && //Thinh Add for new rules: Dia diem => Nganh Hoc
                                             DSNguyenVongs.MaNganh == NganhTheoBo.MaNganh    //Thinh Add for new rules: Dia diem => Nganh Hoc
                                             //(from SinhViens in dbContext.SinhViens
                                             // select new
                                             // {
                                             //     SinhViens.MaHoSo
                                             // }).Contains(new { MaHoSo = HoSoXetTuyens.MaHoSo })
                                             select new
            {
                HoSoXetTuyens.CMDN,
                TinhTrangTrungTuyen = (int?)HoSoXetTuyens.TinhTrangTrungTuyen,
                Tinhs.TenTinh,
                TinhTrang = "Nhập học",
                TenNganh = NganhTheoBo.TeNganh//Thinh ADd for new rule: Dia diem => Nganh Hoc
            }
//).Union
//(
//    from HoSoXetTuyens in dbContext.HoSoXetTuyens
//    from Tinhs in dbContext.Tinhs
//    where
//      HoSoXetTuyens.TruongTHPT.MaTinh == Tinhs.MaTinh &&
//      HoSoXetTuyens.TinhTrangTrungTuyen == 1 &&
//      !
//        (from SinhViens in dbContext.SinhViens
//         select new
//         {
//             SinhViens.MaHoSo
//         }).Contains(new { MaHoSo = HoSoXetTuyens.MaHoSo })
//    select new
//    {
//        CMDN = HoSoXetTuyens.CMDN,
//        TinhTrangTrungTuyen = (int?)HoSoXetTuyens.TinhTrangTrungTuyen,
//        TenTinh = Tinhs.TenTinh,
//        TinhTrang = "Không nhập học"
//    }
                                             )).ToList();
            string result = "";

            foreach (var item in dataListView)
            {
                db.Add(new clssItemSet()
                {
                    item.TenTinh,
                    item.TenNganh
                });
            }

            clssItemSet        uniqueItems = db.GetUniqueItems();
            ClssItemCollection L           = clssApriori.DoApriori(db, sup);
            List <ClssRules>   allRules    = clssApriori.Mine(db, L, con);

            result = "\n" + allRules.Count + " rules \n";

            return(allRules);
        }