public ActionResult DataExplore(string ID) { //讀檔案路徑 Users user = userservice.FindUser(User.Identity.Name); string MapPath = "../../ProjectFiles/" + user.Site + "/" + ID + "/"; ViewBag.prePath = MapPath + ID + "_pre.csv"; ViewBag.corrPath = MapPath + ID + "_corr.csv"; //執行EDA string path = MapPath + ID; string arg = $"{pyPath}preprocessing.py {filePath + user.Site + "/" + ID + "/" + ID + ".csv"} {0} {0} {0} {"null"} {"null"} {"EDA"} {"null"}"; callpython.CMD(); string output = callpython.Execute(arg); DataPreprocess eda = new DataPreprocess(); string[] data = output.Split('/'); eda.col1 = data[0]; eda.col2 = data[1]; eda.col3 = data[2]; eda.col4 = data[3]; eda.col5 = data[4]; eda.col6 = data[5]; return(View(eda)); }
public ActionResult ChooseModel(DataPreprocess data) { ModelViewModel modelView = new ModelViewModel(); modelView.cantfill = data.cantfill; modelView.ProjectId = Convert.ToString(Session["ID"]); modelView.mode = Convert.ToString(Session["Mode"]); if (modelView.mode == "2") { Users user = userservice.FindUser(User.Identity.Name); string MapPath = filePath + user.Site + "/" + modelView.ProjectId + "/"; string path = MapPath; //判斷train, predict資料欄位是否一致 var file1 = Directory.GetFiles(path, modelView.ProjectId + "_pre.csv", SearchOption.AllDirectories); var file2 = Directory.GetFiles(path, "*predict_pre.csv", SearchOption.AllDirectories); string[] lines1 = System.IO.File.ReadAllLines(file1[0], Encoding.UTF8); string[] lines2 = System.IO.File.ReadAllLines(file2[0], Encoding.UTF8); bool compare = lines1[0].SequenceEqual(lines2[0]); if (compare == false) { return(RedirectToAction("ProjectList", "Project", new { compare = compare })); } modelView.ModelList = modelservice.GetAllModelList(modelView.ProjectId).ToList(); string file = path + modelView.ProjectId + "_predict_pre.csv"; string[] lines = System.IO.File.ReadAllLines(file, Encoding.UTF8); modelView.ColList = lines[0].Trim().Split(',').Skip(2).ToArray(); //移除index, date,存入下拉式選單 } return(View(modelView)); }
public ActionResult DataPreprocess() { DataPreprocessViewModel view = new DataPreprocessViewModel(); view.ProjectId = Convert.ToString(Session["ID"]); view.mode = Convert.ToString(Session["Mode"]); //讀檔案路徑 Users user = userservice.FindUser(User.Identity.Name); string MapPath = filePath + user.Site + "/" + view.ProjectId + "/"; string path = MapPath + view.ProjectId; string file, savePath, corrPath; if (view.mode == "2") //predict { file = path + "_predict.csv"; savePath = path + "_predict_pre.csv"; corrPath = "null"; } else { file = path + ".csv"; savePath = path + "_pre.csv"; corrPath = path + "_corr.csv"; } //執行預處理 string arg2 = $"{pyPath}preprocessing.py {file} {0} {0} {"interp1d"} {savePath} {corrPath} {"null"} {"null"}"; callpython.CMD(); string output = callpython.Execute(arg2); //存回傳結果 string[] data = output.Split('/'); DataPreprocess _pre = new DataPreprocess(); _pre.isnull = data[0]; _pre.DeleteCol = data[1].Substring(1).Substring(0, data[1].Length - 2).Split(','); _pre.SameCol = data[2].Substring(1).Substring(0, data[2].Length - 2).Split(','); _pre.abnormal = data[3]; _pre.outlier = data[4]; view.pre = _pre; //dropdownlist string[] lines = System.IO.File.ReadAllLines(file, Encoding.UTF8); view.ColList = lines[0].Trim().Split(',').Skip(1).ToArray(); //移除date,存入下拉式選單 return(View(view)); }
public ActionResult DataPreprocess(DataPreprocessViewModel view) { //讀檔案路徑 Users user = userservice.FindUser(User.Identity.Name); string MapPath = filePath + user.Site + "/" + view.ProjectId + "/"; string path = MapPath + view.ProjectId; string file, savePath, corrPath, select; if (view.mode == "2") //predict { file = path + "_predict.csv"; savePath = path + "_predict_pre.csv"; corrPath = "null"; } else { file = path + ".csv"; savePath = path + "_pre.csv"; corrPath = path + "_corr.csv"; } select = (view.Selected != null) ? String.Join(",", view.Selected.ToArray()) : "null"; //判斷selected是否有值 //執行預處理 string arg = $"{pyPath}preprocessing.py {file} {view.abnormal} {view.outlier} {view.fill} {savePath} {corrPath} {"null"} {select.Replace(' ', '_')}"; //字串不可含空白 callpython.CMD(); string output = callpython.Execute(arg); //無法補值 string[] data = output.Split('/'); DataPreprocess pre = new DataPreprocess(); pre.cantfill = data[5]; //更新執行步驟&時間 if (view.mode == "1") { modelservice.DataSplit(view.ProjectId, view.TrainVal, view.ValidVal, view.TestVal); //存train/valid/test modelservice.UpdateProcess(view.ProjectId, 2); } return(RedirectToAction("ChooseModel", "Model", pre)); }