public ActionResult TrainAnalyser(TrainModel train) { string title = Uri.EscapeDataString(Jobtitle); string location = Uri.EscapeDataString(city + "," + provience); string query = title + location; string site = "https://ca.indeed.com/"; string searchTerm = "jobs?q=" + title + "&l=" + location + "&limit=50&ts=1504132125324&rq=1&fromage=last"; string url = site + searchTerm; var webGet = new HtmlWeb(); webGet.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"; var document = webGet.Load(url); int count = 1; WorkOnCurrentPage(document, site); var pagination = document.DocumentNode.SelectNodes("//div[@class='pagination']/a[@href]").ToArray(); string curPage = ""; foreach (var page in pagination) { count++; curPage = page.GetAttributeValue("href", string.Empty); document = webGet.Load(site + curPage); WorkOnCurrentPage(document, site); } return(View(postings)); }
public async Task <TrainModel> UpdateTrainAsync(TrainModel trainModel) { var trainEntity = new Data.Entities.Train { TrainId = trainModel.TrainId, TrainName = trainModel.TrainName, //Wagons = trainModel.Wagons // .Select(x => new Data.Entities.Wagon() { WagonId = x.WagonId, WagonPosition=x.WagonPosition }) // .ToList() }; trainEntity = await _trainRepository.UpdateAsync(trainEntity); return(new TrainModel { TrainId = trainEntity.TrainId, TrainName = trainEntity.TrainName, Wagons = trainEntity.Wagons .Select(x => new WagonModel() { WagonId = x.WagonId, WagonPosition = x.WagonPosition }) .ToList() }); }
private void AlgoritmAccurancy(weka.core.Instances insts, Classifier classifier, string algoritmName, bool?isNominal = null) { ClassifierManager manager = new ClassifierManager(insts); manager.EliminateTargetAttribute(); if (isNominal == true) { manager.Discreatization(manager.Instance); } else if (isNominal == false) { manager.NominalToBinary(manager.Instance); manager.Normalization(manager.Instance); } manager.Randomize(manager.Instance); TrainModel model = manager.Train(manager.Instance, classifier); SuccessfulAlgorithm.Add(new AlgorithmModel() { SuccessRatio = manager.FindAccurancy(), AlgorithName = algoritmName, TrainModel = model });; }
/// <summary> /// Convert a <see cref="Train"/> instance into a <see cref="TrainModel"/> instance. /// </summary> /// <param name="train">The object to convert.</param> /// <returns>A <see cref="TrainModel"/> instance containing the same data as the parameter.</returns> public static TrainModel ToTrainModel(this Train train) { if (train is null) { throw new ArgumentNullException(nameof(train)); } TrainModel model = new TrainModel { Id = train.Id, GraphProperties = train.GraphProperties.ToGraphTrainPropertiesModel(), Headcode = train.Headcode, LocoDiagram = train.LocoDiagram, TrainClassId = train.TrainClass?.Id, IncludeSeparatorAbove = train.IncludeSeparatorAbove, IncludeSeparatorBelow = train.IncludeSeparatorBelow, InlineNote = train.InlineNote ?? string.Empty, ToWork = train.ToWork?.ToToWorkModel(), LocoToWork = train.LocoToWork?.ToToWorkModel(), }; model.FootnoteIds.AddRange(train.Footnotes.Select(n => n.Id)); model.TrainTimes.AddRange(train.TrainTimes.Select(tt => tt.ToTrainLocationTimeModel())); return(model); }
public void dispatchMBOTrain(int line, double speed, int auth) { currentLineSelection = line; sugSpeed = speed; sugAuth = auth; trainCounter++; Train train = new Train(trainCounter, sugSpeed, sugAuth); myTrainList.Add(train); if (currentLineSelection == 1) //green { train.prevBlock = 152; train.currBlock = 152; } else //red { train.prevBlock = 229; train.currBlock = 229; } tm_window = new TrainModel(currentLineSelection, trainCounter); trainModelArray[trainCounter] = tm_window; //starts at 1 and skips 0 element, noted for the for loop tm_window.Show(); module.dispatchNewTrain(trainCounter, tm_window, sugSpeed, sugAuth); train.authority = sugAuth; train.suggestedSpeed = sugSpeed; }
public void TestTrainModel1() { var(a, v1, mode) = TrainModel.AccelerationToFullyStopAfter2( v: 0.46089262f, distToGoal: 0.08170131f, accelMax: 1.0f, decelNom: 1.3f, maxVelocity: 80.0f / 3.6f, dt: 0.1f); Assert.Equal(0.46089414, v1, 6); Assert.Equal(-1.3f, a, 3); }
public void TrainModelClass_Constructor_SetsFootnoteIdsPropertyToEmptyCollection() { TrainModel testOutput = new TrainModel(); Assert.IsNotNull(testOutput.FootnoteIds); Assert.AreEqual(0, testOutput.FootnoteIds.Count); }
public async Task <IActionResult> Edit(int id, [Bind("TrainId,TrainName,TrainCompanyName,TrainTitle,TrainDescription,TrainMap,TrainRating,TrainSeatType,TrainSeatPrice,DepartureTime,TrainDepartureLocation,TrainArrivalLocation,ArrivalTime,ImageName")] TrainModel trainModel) { if (id != trainModel.TrainId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(trainModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TrainModelExists(trainModel.TrainId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(trainModel)); }
private void button2_Click(object sender, EventArgs e) { List <Data> Trainingdataset = Utility.LoadDataset(DatasetType.Training); List <Data> Testingingdataset = Utility.LoadDataset(DatasetType.Testing); TrainModel train = null; if (comboBox1.SelectedIndex == 0) { train = new TrainModel(ViewModel.FeatureExtraction.FeatureExtractionType.EuclideanDistance, ClassifierType.Bayesian); } else if (comboBox1.SelectedIndex == 1) { train = new TrainModel(ViewModel.FeatureExtraction.FeatureExtractionType.EuclideanDistance, ClassifierType.KNearestNeighbour); } train.Train(Trainingdataset); ScoreModel score = new ScoreModel(train, int.Parse(KNNTextBox.Text)); score.Score(Testingingdataset); dataGridView1.Rows.Clear(); for (int i = 0; i < score.ConfussionMatrix.GetLength(0); ++i) { string[] arr = new string[score.ConfussionMatrix.GetLength(1)]; for (int j = 0; j < score.ConfussionMatrix.GetLength(1); ++j) { arr[j] = score.ConfussionMatrix[i, j].ToString(); } dataGridView1.Rows.Add(arr); } OverallAccuracyLabel.Text = score.Accuracy.ToString(); }
public async Task <Train> AddTrainAsync(TrainModel TrainModel, string station) { _logger.LogInformation("Got trainModel to create", TrainModel); var train = _imapper.Map <Train>(TrainModel); train.FormStation = _context.Station.Where(s => s.Code.StartsWith(TrainModel.Index.Substring(0, 4))) .Select(s => s.Code) .FirstOrDefault(); train.DestinationStation = _context.Station.Where(s => s.Code.StartsWith(TrainModel.Index.Substring(9, 4))) .Select(s => s.Code) .FirstOrDefault(); train.Dislocation = station; train.Ordinal = await GetNextOrdinal(station); _logger.LogDebug("Found {FormStation} {DestinationStation}", train.FormStation, train.DestinationStation); _logger.LogInformation("Saving train", train); _context.Train.Add(train); var result = await _context.SaveChangesAsync(); _logger.LogInformation($"Saved {result} of 1 record"); return(train); }
/// <summary> /// Convert a <see cref="Train" /> instance to a <see cref="TrainModel" /> instance. /// </summary> /// <param name="train">The object to be converted.</param> /// <returns>A <see cref="TrainModel" /> instance containing the same data as the parameter in serialisable form.</returns> /// <exception cref="NullReferenceException">Thrown if the parameter is <c>null</c>.</exception> public static TrainModel ToYamlTrainModel(this Train train) { if (train is null) { throw new NullReferenceException(); } TrainModel model = new TrainModel { Id = train.Id, GraphProperties = train.GraphProperties.ToYamlGraphTrainPropertiesModel(), Headcode = train.Headcode, LocoDiagram = train.LocoDiagram, TrainClassId = train.TrainClassId, IncludeSeparatorAbove = train.IncludeSeparatorAbove, IncludeSeparatorBelow = train.IncludeSeparatorBelow, InlineNote = train.InlineNote, SetToWork = train.ToWork?.ToYamlToWorkModel(), LocoToWork = train.LocoToWork?.ToYamlToWorkModel(), }; model.FootnoteIds.AddRange(train.Footnotes.Select(n => n.Id)); model.TrainTimes.AddRange(train.TrainTimes.Select(tt => tt.ToYamlTrainLocationTimeModel())); return(model); }
public Tuple <List <TrainModel>, int> Trains(TrainModel model) { var where = new StringBuilder("1=1"); if (!string.IsNullOrWhiteSpace(model.KeyWord)) { where.Append($" and tte.TrainTeacherNames like '%{model.KeyWord}%' "); } var pre = @"select t.Id, (SELECT STUFF((SELECT ','+ Cast(UserId as varchar(100)) FROM TrainTeacher (NOLOCK) where TrainId=t.Id and IsValid=1 for xml path('')),1,1,'')) TrainTeacherIdStr, (SELECT STUFF((SELECT ','+ u.UserName FROM TrainTeacher tt left join [User] u on tt.userid=u.UserId where TrainId=t.Id and tt.IsValid=1 for xml path('')),1,1,'')) TrainTeacherNames into #temp_trainers from Train t;"; var cols = @"select t.*,acc.CateName,c.ClassName, tte.TrainTeacherIdStr,tte.TrainTeacherNames"; var sql = $@"from Train t left join AtomCateConfig acc on t.CourseCode=acc.CateCode left join Classes c on c.Id=t.ClassId left join #temp_trainers tte on tte.Id=t.Id where {where} "; var cntSql = $"{pre} select count(1) {sql} "; var dataSql = $"{pre} {cols} {sql} order by t.EditTime desc OFFSET ({model.Skip}) ROW FETCH NEXT {model.PageSize} rows only "; var cnt = db.Database.SqlQuery <int>(cntSql).First(); var data = db.Database.SqlQuery <TrainModel>(dataSql).ToList(); data.ForEach(t => t.TeacherIds = ListConverter.StringToListInt(t.TrainTeacherIdStr, ',')); return(new Tuple <List <TrainModel>, int>(data, cnt)); }
public async Task <IActionResult> Train(TrainModel model) { if (!ModelState.IsValid) { return(View()); } HttpOperationResponse <Person> response = await _client.PersonGroupPerson.CreateWithHttpMessagesAsync("1", model.Name); if (model.Base64Images != null) { if (model.Base64Images.Count > 8) { return(Error()); } foreach (string imageString in model.Base64Images) { byte[] bytes = Convert.FromBase64String(imageString); using (MemoryStream stream = new MemoryStream(bytes)) { try { await _client.PersonGroupPerson.AddPersonFaceFromStreamWithHttpMessagesAsync("1", response.Body.PersonId, stream); } catch (Exception) { // ignored } } } } if (model.UploadedImages != null) { if (model.UploadedImages.Count > 8) { return(Error()); } foreach (IFormFile uploadedImage in model.UploadedImages) { BinaryReader reader = new BinaryReader(uploadedImage.OpenReadStream()); var readBytes = reader.ReadBytes((int)uploadedImage.Length); using (MemoryStream stream = new MemoryStream(readBytes)) { await _client.PersonGroupPerson.AddPersonFaceFromStreamWithHttpMessagesAsync("1", response.Body.PersonId, stream); } } } await _client.PersonGroup.TrainWithHttpMessagesAsync("1"); UpdatePersons(); return(View()); }
public void AddTrainModels(TrainModel trainModel, bool retrain = true) { addTrainModel(trainModel); if (retrain) { train(); } }
public void TrainModelClass_WriteXmlMethod_ThrowsArgumentNullException_IfParameterIsNull() { TrainModel testObject = new TrainModel(); testObject.WriteXml(null); Assert.Fail(); }
public Train(string alias, TrainModel model, int maxCapacity, string lineId) { Alias = alias; Model = model; MaxCapacity = maxCapacity; LineId = lineId; CurrentCapacity = 0; }
/// <summary> /// Runs the batch. /// </summary> /// <param name="dataSet">Data set.</param> /// <param name="priors">Priors.</param> public void RunBatch(DataSet dataSet, Marginals priors, int niter = 1) { // Posteriors = priors; // for (int rr = 0; rr < dataSet.NumberOfResidents; ++rr) // { // Posteriors = TrainModel.Train(dataSet.GetSubSet(rr), Posteriors); // } Posteriors = TrainModel.Train(dataSet, priors, niter); }
private void ClassificationButton_Click(object sender, EventArgs e) { List <Data> Trainingdataset = Utility.LoadDataset(DatasetType.Training); TrainModel train = null; if (comboBox1.SelectedIndex == 0) { train = new TrainModel(ViewModel.FeatureExtraction.FeatureExtractionType.EuclideanDistance, ClassifierType.Bayesian); } else if (comboBox1.SelectedIndex == 1) { train = new TrainModel(ViewModel.FeatureExtraction.FeatureExtractionType.EuclideanDistance, ClassifierType.KNearestNeighbour); } train.Train(Trainingdataset); OpenFileDialog f = new OpenFileDialog(); if (DialogResult.OK == f.ShowDialog()) { ScoreModel score = new ScoreModel(train, int.Parse(KNNTextBox.Text)); List <Vector2> features = Utility.LoadPoints(f.FileName); int estimatedClass = score.Classify(features); ExpectedClassLabel.Text = estimatedClass.ToString(); AppModel app = new AppModel(@"C:\Program Files (x86)\Notepad++\notepad++.exe"); try { if (estimatedClass == 0) { app.Close(); } else if (estimatedClass == 1) { app.Minimize(); } else if (estimatedClass == 2) { app.Open(); } else if (estimatedClass == 3) { app.Restore(); } } catch { MessageBox.Show("Couldn't take that action, please make sure that the specified program is already opened"); } } /*for(int i=0;i<40;) * { * Vector2 a = new Vector2(); * a.x = double.Parse(inputarr[i++].Text); * a.y = double.Parse(inputarr[i++].Text); * features.Add(a); * }*/ }
public async Task <ActionResult> Train() { IFacesTrainApi facesTrainApi = new FacesTrainApi(); var trainModel = new TrainModel() { Persons = await facesTrainApi.GetPersonsMetaDataAsync() }; return(View("Train", trainModel)); }
public async Task <IActionResult> Create([Bind("TrainId,TrainName,TrainCompanyName,TrainTitle,TrainDescription,TrainMap,TrainRating,TrainSeatType,TrainSeatPrice,DepartureTime,TrainDepartureLocation,TrainArrivalLocation,ArrivalTime,ImageName")] TrainModel trainModel) { if (ModelState.IsValid) { _context.Add(trainModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(trainModel)); }
public async Task <ActionResult <TrainModel> > CreateTrainAsync(CreateTrainModel createTrainModel) { var trainModel = new TrainModel { TrainName = createTrainModel.TrainName, Wagons = null }; var createdTrain = await _trainService.CreateTrainAsync(trainModel); return(CreatedAtAction(nameof(GetTrainAsync), new { TrainId = createdTrain.TrainId }, createdTrain)); }
private bool addTrainModel(TrainModel trainModel) { if (trainModel != null) { if (trainModel.ImageGray != null) { trainData.Add(trainModel); } } return(false); }
public void TrainModelExtensionsClass_ToTrainMethod_ThrowsArgumentNullException_IfFirstParameterIsNull() { TrainModel testObject = null; Dictionary <string, Location> testParam1 = new Dictionary <string, Location>(); Dictionary <string, TrainClass> testParam2 = new Dictionary <string, TrainClass>(); Dictionary <string, Note> testParam3 = new Dictionary <string, Note>(); DocumentOptions testParam4 = new DocumentOptions(); _ = testObject.ToTrain(testParam1, testParam2, testParam3, testParam4); Assert.Fail(); }
/* * called by trainSimulator * then updates other modules with time */ public void updateTime(String time) { updateTimeLabel.Text = time; for (int i = 1; i <= trainCounter; i++) { tm_window = trainModelArray[i]; if (tm_window != null) { Invoke(new MethodInvoker(delegate { tm_window.updateTime(time); })); } } }
public async Task UpdateTrainParams(TrainModel trainModel) { _logger.LogInformation("Got trainModel to update", trainModel); Train train = await FindTrain(trainModel.Index); train = _imapper.Map <Train>(trainModel); _context.Train.Update(train); var affected = await _context.SaveChangesAsync(); _logger.LogInformation($"Saved {affected} of 1 record"); }
public void beginButton_Click(object sender, EventArgs e) { start = 1; trackControllerWindow = new TrackControllerWindow(); trackControllerWindow.Show(); trackModelWindow = new TrackModelUI(); trackModelWindow.Show(); MBOWindow = new MBO(); MBOWindow.Show(); mainOffice = new Office(); mainOffice.Show(); trainModelWindow = new TrainModel(); }
public TrainModel GetTrain(Guid id) { var dbTrain = _dbContext.Trains.First(e => e.Id == id); var train = new TrainModel() { Id = dbTrain.Id, Name = dbTrain.Name, Passagers = dbTrain.Passagers }; return(train); }
private void InitTrainButtons(Button button, int i) { button.onClick.AddListener(() => { RestTrainButtonColor(); TrainButtons[i].OnClick(); TiltleText.text = TrainButtons[i].text.text; TrainModelData data = new TrainModelData(); TrainModel trainModel = (TrainModel)Enum.ToObject(typeof(TrainModel), i); data.trainModel = trainModel.ToString(); UdpSclient.Instance.SendDataToSever(ParmaterCodes.TrainModelData, data); }); }
public void TrainModelClass_WriteXmlMethod_ThrowsArgumentNullExceptionWithCorrectParamNameProperty_IfParameterIsNull() { TrainModel testObject = new TrainModel(); try { testObject.WriteXml(null); Assert.Fail(); } catch (ArgumentNullException ex) { Assert.AreEqual("writer", ex.ParamName); } }
//点击了查询按钮,它将添加到查询按钮和InputField的提交 事件 public void OnQuaryButtonClick() { if (inputLabel.text != "" && Global.appkey != "") { //如果用户输入了appkey,和车次名称,则需要我们去请求数据 #region 坑 坑 坑 // textList在激活后会清空label的显示,所以我们需要在请求数据之前,就激活它,并且最好手动清空一次 trainInfoShow.SetActive(true); trainLabel.Clear(); stationInfoShow.SetActive(true); stationLabel.Clear(); #endregion #region 查询数据 Global.trainName = inputLabel.text; //获取用户输入的车次名称 //调用 GetTrainStationInfo请求数据 并用请求到的数据来刷新显示 trainController.GetTrainStationInfo((Dictionary<string, TrainModel> trainDic) => { //这里也需要注意,我们为什么不直接使用我们获取到的模型? //原因是,我们如果使用获取到的模型,如果后续我们操作模型的话, //由于模型是引用类型的,我们修改的话,会导致模型变化, //下次再使用的话,模型就变了,导致程序出现莫名其妙的Bug。 //所以我们在模型类中添加一个静态的通过模型来构建新模型的方法, //修改的话修改的是后来重新创建的模型,跟我们直接获取的模型没有关系 trainModel = TrainModel.CreateModel(trainDic[Global.trainName]); UpdateTrainInfo(); //更新车次显示 }, (Dictionary<string, Dictionary<string, StationModel>> stationDic) => { stationModelsList.Clear(); //清空站点列表 //定义一个站点数据字典,用来保存获取到的站点信息 Dictionary<string, StationModel> dic = stationDic["station_list"]; //遍历所有的站点 foreach (string id in dic.Keys) { //将站点加到stationModelsList中 stationModelsList.Add(StationModel.CreateModel(dic[id])); } selectedIndex = 0; //初始选中的站点索引更新为第一个 length = stationModelsList.Count; //获得站点的个数, UpdateStationInfo(); //更新站点显示 }, (string error) => { HideShow(); //隐藏显示 UpdateErrorInfo(error); //更新出错显示 }); #endregion } }
public void TrainModelExtensionsClass_ToTrainMethod_ThrowsArgumentNullExceptionWithCorrectParamNameProperty_IfFirstParameterIsNull() { TrainModel testObject = null; Dictionary <string, Location> testParam1 = new Dictionary <string, Location>(); Dictionary <string, TrainClass> testParam2 = new Dictionary <string, TrainClass>(); Dictionary <string, Note> testParam3 = new Dictionary <string, Note>(); DocumentOptions testParam4 = new DocumentOptions(); try { _ = testObject.ToTrain(testParam1, testParam2, testParam3, testParam4); Assert.Fail(); } catch (ArgumentNullException ex) { Assert.AreEqual("model", ex.ParamName); } }
// Use this for initialization // public void init(int i, int j, Vector2 start_dir, int num_tiles_w, int num_tiles_h){ public void init(int i, int j, int start_dir, TrainManager owner) { this.owner = owner; this.num_tiles_w = owner.num_tiles_w; this.num_tiles_h = owner.num_tiles_h; this.n = owner.owner.n; this.direction = start_dir; tile_width = Screen.width / num_tiles_w; this.transform.rotation = Quaternion.Euler(0f, 0f, (90f * direction)%360f); this.transform.Rotate (Vector2.right * direction); float[] pos = position (i, j); location = new Vector2 (pos [0], pos [1]); current_tile = owner.owner.board.tiles [i] [j]; this.transform.position = Camera.main.ScreenToWorldPoint ( new Vector3 (location.x, location.y, 8)); GameObject modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad); // Create a quad object for holding the gem texture. model = modelObject.AddComponent<TrainModel>(); // Add a gemModel script to control visuals of the gem. model.init(this); }
private void updateTrainInfo(TrainModel resultTrain) { labelTrain.Text = ""; // Timetable for (int i = 0; i < resultTrain.timeTableRows.Count() - 1; i++) { // If the train stops at station if (resultTrain.timeTableRows[i].trainStopping) { TableRow trainStop = new TableRow(); TableCell trainStopStation = new TableCell(); TableCell trainStopTrackNumber = new TableCell(); TableCell trainArrivalTime = new TableCell(); TableCell trainDepartureTime = new TableCell(); string stationName; // Check that row is not last if (i < resultTrain.timeTableRows.Count()) { // Links to next row or is first row if (resultTrain.timeTableRows[i].type == "ARRIVAL" || i == 0) { // STATION NAME try { stationNames.TryGetValue(resultTrain.timeTableRows[i].stationShortCode, out stationName); trainStopStation.Text = "<a href='asemat?query=" + stationName + "'>" + stationName; } catch (Exception ex) { Debug.WriteLine("AKVR - updateTrainInfo - stationNames.TryGetValue fails: " + ex.Message); } // TRACK NUMBER trainStopTrackNumber.Text = resultTrain.timeTableRows[i].commercialTrack; // ARRIVAL TIME trainArrivalTime.Text = (i != 0) ? resultTrain.timeTableRows[i].scheduledTime.ToShortTimeString() : ""; // DEPARTURE TIME trainDepartureTime.Text = (i != 0) ? resultTrain.timeTableRows[i+1].scheduledTime.ToShortTimeString() : resultTrain.timeTableRows[i].scheduledTime.ToShortTimeString(); // Add the cells in a row trainStop.Cells.Add(trainStopStation); trainStop.Cells.Add(trainStopTrackNumber); trainStop.Cells.Add(trainArrivalTime); trainStop.Cells.Add(trainDepartureTime); // Add row to table tableTrainResults.Rows.Add(trainStop); } } } } }
public BayesianClassifier(TrainModel trainedModel) { this.trainedModel = trainedModel; prior = 1.0 / trainedModel.NumberofClasses; }
//静态的创建TrainModel的方法 ,这个方法在后面的显示脚本中会用到 public static TrainModel CreateModel(TrainModel model) { return new TrainModel(model.trainName, model.trainStart, model.trainEnd, model.trainStartTime, model.trainEndTime, model.trainMileage); }
public KNearestNeighbour(TrainModel trainModel, int K) { this.trainedModel = trainModel; k = K; }
public KNearestNeighbour(TrainModel trainModel) { this.trainedModel = trainModel; k = 3; }