/// <summary> /// Creates model and call learning. /// </summary> public bool CreateStoreModel() { var allItems = new Dictionary <IOutlookItem, string>(); foreach (var folder in StoreFolders) { GetAllItems(folder.Value, allItems); } var listInputs = allItems.Select(k => k.Key.GetInput()).ToArray(); var listSubjects = allItems.Select(k => k.Key.GetSubject()).ToArray();; var listTexts = allItems.Select(k => k.Key.GetText()).ToArray();; var listOutputs = allItems.Select(v => v.Value).ToArray(); var uniqueFolders = new HashSet <string>(listOutputs); if (uniqueFolders.Count > 1) { Accord.CreateModel(listInputs, listSubjects, listTexts, listOutputs); return(true); } MessageBox.Show("Store " + Store.DisplayName + " not analyzed, not enough folders with items"); return(false); }
public Vehicle CreateVehicle(string model, string color, int numDoors, string[] options = string[0]) { Vehicle vehicle = null; if (model.Equals("Civic")) { // Ooh! My favorite! vehicle = new Civic(); vehicle.Doors = numDoors; vehicle.Color = color; vehicle.Options = options; } else if (model.Equals("Accord")) { // Only comes in 4 doors. So, ignore numDoors. vehicle = new Accord(); vehicle.Color = color; vehicle.Options = options; } else if (model.Equals("CR-V")) { // Only comes in 4 doors. So, ignore numDoors. vehicle = new CRV(); vehicle.Color = color; vehicle.Options = options; } else { throw new InvalidArgumentException("Cannot make requested model for Honda"); } return vehicle; }
public Sample(string imageName, Accord.Point[] imagePoints, Vector3[] modelPoints, float focalLength, bool isCoplanar) { ImageName = imageName; ImagePoints = imagePoints; ModelPoints = modelPoints; FocalLength = focalLength; IsCoplanar = isCoplanar; }
public ActionResult buildVehicle(string make, string model, string color, int numDoors, string[] options = string[0]) { Vehicle vehicle = null; if (make.Equals("Honda")) { if (model.Equals("Civic")) { // Ooh! My favorite! vehicle = new Civic(); vehicle.Doors = numDoors; vehicle.Color = color; vehicle.Options = options; } else if (model.Equals("Accord")) { // Only comes in 4 doors. So, ignore numDoors. vehicle = new Accord(); vehicle.Color = color; vehicle.Options = options; } else if (model.Equals("CR-V")) { // Only comes in 4 doors. So, ignore numDoors. vehicle = new CRV(); vehicle.Color = color; vehicle.Options = options; } else { throw new InvalidArgumentException("Cannot make requested model for Honda"); } } else if (make.Equals("Chevrolet")) { if (model.Equals("Suburban")) { vehicle = new Suburban(); vehicle.Doors = numDoors; vehicle.Color = color; vehicle.Options = options; } else if (model.Equals("Silverado")) { vehicle = new Silverado(); vehicle.Doors = numDoors; vehicle.Color = color; vehicle.Options = options; } else { throw new InvalidArgumentException("Cannot make requested model for Chevrolet"); } } else if (make.Equals("BMW")) { // Pompus luxury vehicle. } else if (make.Equals("Ferrari")) { // Not likely in my lifetime. } else if (make.Equals("Lamborghini")) { // I wish. } // Save. this.vehicleContext.Attach(vehicle); this.vehicleContext.SaveAll(); // Display our newly created vehicle. return View("BuildVehicle", vehicle); }
/// <summary> /// Return scores for item. /// </summary> /// <param name="item">Item to be analyzed</param> public Dictionary <string, double> GetScoresForMail(IOutlookItem item) { if (item != null && Accord.IsReady()) { var input = item.GetInput(); var subject = item.GetSubject(); var text = item.GetText(); var results = Accord.DecideFolder(input, subject, text); return(results); } return(new Dictionary <string, double>()); }
void generateMultipleRow(int quAccord) { multipleRow.Clear(); for (int i = 0; i < 2; i++) { Row row = new Row(); multipleRow.Add(row); for (int j = 0; j < quAccord; j++) { Accord accord = new Accord(); int startNote = rnd.Next(4, 16); accord.Add(startNote); accord.Add(startNote + rnd.Next(1, 4)); accord.Add(startNote - rnd.Next(1, 4)); accord.Sort(); row.Add(accord); } } }
protected void BtnSearch_Click(object sender, EventArgs e) { kc.KCCategorySNo = Convert.ToInt32(ddlKCCat.SelectedValue); kc.Unit_SNo = Convert.ToInt32(ddlUnit.SelectedValue); if (ddlProductLine.SelectedIndex != 0) { kc.ProductLine_SNo = Convert.ToInt32(ddlProductLine.SelectedValue); } if (Ddlprodctgroup.SelectedIndex != 0) { kc.ProductGroup_SNo = Convert.ToInt32(Ddlprodctgroup.SelectedValue); } DataSet ds = kc.SearchDocument(lblRowCount); ViewState["dsTable"] = ds.Tables[0]; if (ds.Tables[0] != null) { DataTable dtdistinct = ds.Tables[0].DefaultView.ToTable(true, "Productline_Desc"); Accord.DataSource = dtdistinct.DefaultView; Accord.DataBind(); } }
public Song AddAccords(string[] elements, int idSong) { List <Accord> temp = new List <Accord>(); Song song = db.Songs.Include("Performer").Include("Accords").Where(i => i.Id == idSong).FirstOrDefault(); if (song != null && elements[0] != "") { foreach (var item in elements) { temp.Add(db.Accords.Where(n => n.Name == item.TrimStart()).FirstOrDefault()); } foreach (var item in temp) { Accord accord = new Accord(); accord.Name = item.Name; accord.UrlImage = item.UrlImage; accord.Song = song; db.Accords.Add(accord); } db.SaveChanges(); } return(song); }
/// <summary> /// Matches two sets of points using RANSAC. /// </summary> /// /// <returns>The homography matrix matching x1 and x2.</returns> /// public MatrixH Estimate(Accord.Point[] points1, Accord.Point[] points2) { // Initial argument checks if (points1.Length != points2.Length) throw new ArgumentException("The number of points should be equal."); if (points1.Length < 4) throw new ArgumentException("At least four points are required to fit an homography"); PointF[] p1 = new PointF[points1.Length]; PointF[] p2 = new PointF[points2.Length]; for (int i = 0; i < points1.Length; i++) { p1[i] = new PointF(points1[i].X, points1[i].Y); p2[i] = new PointF(points2[i].X, points2[i].Y); } return Estimate(p1, p2); }
/// <summary> /// Matches two sets of points using RANSAC. /// </summary> /// /// <returns>The homography matrix matching x1 and x2.</returns> /// public MatrixH Estimate(Accord.Point[][] points) { return Estimate(points[0], points[1]); }
public void Delete(int id) { Accord accord = db.Accords.Find(id); if (accord != null) db.Accords.Remove(accord); }
public void Create(Accord accord) { db.Accords.Add(accord); }
public void no_sample_test() { // Declare some boolean data bool[,] source = { // v1,v2,v3,v4,v5,v6,v7,v8,result { true, true, false, true, true, false, false, false, false }, { true, true, true, true, true, false, false, false, false }, { true, false, true, true, true, false, false, true, false }, { true, true, true, true, true, false, false, true, false }, { false, false, true, true, true, false, false, true, false }, { true, true, true, true, false, false, false, false, false }, { false, true, true, false, true, false, false, false, false }, { true, true, true, false, true, false, false, false, false }, { false, true, true, false, true, false, false, true, false }, { false, true, true, true, true, false, false, true, false }, { false, true, true, false, false, false, false, false, false }, { true, false, false, true, false, false, false, true, true }, { true, true, false, true, false, false, false, true, true }, { true, true, true, true, false, false, false, true, true }, { false, true, true, true, false, true, true, true, true }, { true, true, false, false, false, true, true, true, true }, { false, true, false, false, false, true, true, true, true }, { true, true, true, true, false, true, true, true, true }, { false, false, false, false, false, true, true, true, true }, { true, true, false, true, false, true, true, true, true }, { false, true, false, true, false, true, true, true, true }, { false, true, true, false, false, true, true, true, true }, }; // Evaluation of a single point int[] sp = new[] { false, false, false, false, true, true, true, true }.ToInt32(); // Transform to integers, then to jagged (matrix with [][] instead of [,]) int[][] data = source.ToInt32().ToJagged(); // Classification setup var inputs = data.Get(null, 0, 8); // select all rows, with cols 0 to 8 var outputs = data.GetColumn(8); // select last column var learner2 = new NaiveBayesLearning<GeneralDiscreteDistribution, GeneralDiscreteOptions, int>(); learner2.Options.InnerOption.UseLaplaceRule = true; learner2.Distribution = (i, j) => new GeneralDiscreteDistribution(symbols: 2); learner2.ParallelOptions.MaxDegreeOfParallelism = 1; var nb2 = learner2.Learn(inputs, outputs); test(nb2, inputs, sp); var learner1 = new NaiveBayesLearning(); learner1.Options.InnerOption.UseLaplaceRule = true; learner2.ParallelOptions.MaxDegreeOfParallelism = 1; var nb1 = learner1.Learn(inputs, outputs); test(nb1, inputs, sp); }
/// <summary> /// Matches two sets of points using RANSAC. /// </summary> /// /// <returns>The homography matrix matching x1 and x2.</returns> /// public float[,] Estimate(Accord.Point[] points1, Accord.Point[] points2) { // Initial argument checks if (points1.Length != points2.Length) throw new ArgumentException("The number of points should be equal."); if (points1.Length < 7) throw new ArgumentException("At least eight points are required."); PointF[] p1 = new PointF[points1.Length]; PointF[] p2 = new PointF[points2.Length]; for (int i = 0; i < points1.Length; i++) { p1[i] = new PointF(points1[i].X, points1[i].Y); p2[i] = new PointF(points2[i].X, points2[i].Y); } return Estimate(p1, p2); }
public bool ParsingData() { HtmlDocument HD = new HtmlDocument(); string url_songs, url_one_song, urlName, urlNameVideo = ""; string url, count_views, count_songs, name_of_group; int count_for_cicle = 0; var web = new HtmlWeb { AutoDetectEncoding = false, OverrideEncoding = Encoding.UTF8, }; for (int i = 0; i < 3; i++) { url = "https://amdm.ru/chords/page" + (i + 1) + "/"; HD = web.Load(url); HtmlNodeCollection NoAltElements = HD.DocumentNode.SelectNodes("//td[@class='artist_name']/a"); if (NoAltElements != null) { foreach (HtmlNode hn in NoAltElements) { if (hn.OuterHtml.Contains("//amdm.ru/akkordi")) { url_songs = "https:" + hn.GetAttributeValue("href", "href"); HtmlNode node_count_song = hn.ParentNode.NextSibling; count_songs = node_count_song.InnerText.Trim(); HtmlNode node_count_views = node_count_song.NextSibling; count_views = node_count_views.InnerText.Trim(); var a = url_songs.Split('/'); urlName = a[a.Length - 2]; name_of_group = hn.InnerText.Trim(); Performer performer = new Performer(); count_for_cicle = 0; HD = web.Load(url_songs + "wiki/"); HtmlNode html_node = HD.DocumentNode.SelectSingleNode("//div[@class='artist-profile__bio']"); if (html_node.FirstChild != null) { html_node.RemoveChild(html_node.FirstChild); } performer.Biography = html_node.InnerHtml; Thread.Sleep(15000); HD = web.Load(url_songs); HtmlNode ShortBio = HD.DocumentNode.SelectSingleNode("//div[@class='artist-profile__bio']"); if (ShortBio.FirstChild != null) { ShortBio.RemoveChild(ShortBio.FirstChild); ShortBio.RemoveChild(ShortBio.LastChild); } HtmlNode UrlImage = HD.DocumentNode.SelectSingleNode("//div[@class='artist-profile__photo debug1']"); int count_songsINT = 0; if (Int32.TryParse(count_songs, NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out count_songsINT)) { performer.CountOfSongs = count_songsINT; } int count_viewsINT = 0; if (Int32.TryParse(count_views, NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out count_viewsINT)) { performer.Views = count_viewsINT; } performer.Name = name_of_group; performer.ShortBiography = ShortBio.InnerHtml; performer.UrlImage = UrlImage.FirstChild.GetAttributeValue("src", ""); performer.UrlName = urlName; Database.Performers.Create(performer); Database.Save(); //выбирае деревья из класса написанного в textBox и элемента написанного HtmlNodeCollection Elements = HD.DocumentNode.SelectNodes("//td/a"); if (Elements != null) { foreach (HtmlNode hn3 in Elements) { if (count_for_cicle == 35) { break; } if (hn3.OuterHtml.Contains("//amdm.ru/akkordi")) { url_one_song = "https:" + hn3.GetAttributeValue("href", "href"); node_count_views = hn3.ParentNode.NextSibling.NextSibling; count_views = node_count_views.InnerText.Trim(); string name = hn3.InnerText.Trim(); count_for_cicle++; HD = web.Load(url_one_song); HtmlNode html_node_text = HD.DocumentNode.SelectSingleNode("//div[@class='b-podbor__text']/pre"); HtmlNode html_node_video = HD.DocumentNode.SelectSingleNode("//div[@class='b-video']"); if (html_node_video != null) { urlNameVideo = html_node_video.FirstChild.NextSibling.FirstChild.GetAttributeValue("src", ""); } else { urlNameVideo = ""; } Song song = new Song(); song.Name = name; int count_viewsToINT = 0; if (Int32.TryParse(count_views, NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out count_viewsToINT)) { song.Views = count_viewsToINT; } song.Text = html_node_text.InnerHtml; song.Performer = performer; song.UrlVideo = urlNameVideo; Database.Songs.Create(song); Database.Save(); Thread.Sleep(1000); //выбирае деревья из класса написанного в textBox и элемента написанного HtmlNodeCollection Elements2 = HD.DocumentNode.SelectNodes("//div[@id='song_chords']/img"); if (Elements2 != null) { foreach (HtmlNode hn4 in Elements2) { Accord accord = new Accord(); accord.Name = (hn4.GetAttributeValue("alt", "")).TrimStart(); accord.UrlImage = hn4.GetAttributeValue("src", ""); accord.Song = song; Database.Accords.Create(accord); Database.Save(); } } } } } } } } else { return(false); } Thread.Sleep(60000); } return(true); }
/// <summary> /// /// </summary> void draw() { graphics.Clear(Color.White); Pen myPen = new Pen(Color.Black, 2); SolidBrush myBrush = new SolidBrush(System.Drawing.Color.Black); //Рисуем нотоносцы for (int j = 0; j < 2; j++) { for (int i = 0; i < 5; i++) { graphics.DrawLine(myPen, xStart, yStart + i * rowHeight + j * shift, xStart + rowLen, yStart + i * rowHeight + j * shift ); } } //Рисуем ноты if (quNoteInMultipleRow > 0) { const int noteShift = 2; int fistNoteShift = (rowLen - ((quNoteInMultipleRow - 1) * noteStep)) / 2; for (int j = 0; j < multipleRow.Count; j++) { Row row = multipleRow[j]; for (int i = 0; i < row.Count; i++) { Accord accord = row[i]; bool needShift = false; for (int noteNum = 0; noteNum < accord.Count; noteNum++) { int note = accord[noteNum]; if (noteNum - 1 > 0 && Math.Abs((accord[noteNum - 1] - note)) == 1) { needShift = true; } if (noteNum + 1 < accord.Count && Math.Abs((accord[noteNum + 1] - note)) == 1) { needShift = true; } } for (int noteNum = 0; noteNum < accord.Count; noteNum++) { int note = accord[noteNum]; int noteShiftVector = noteNum % 2 == 0 ? -1 : 1; int x = xStart + i * noteStep + fistNoteShift + (needShift ? noteShiftVector * noteWidth / 2 : 0); int y = yStart //Поле + noteShift //Сдвиг ноты относительно нотоносца + j * shift //Номер ряда нотоносцев + (((note - shiftFistNote) * rowHeight) / 2); //Номер ноты //Нота graphics.DrawArc(myPen, x, y, noteWidth, noteHeight, 0, 180); graphics.FillPie(myBrush, x, y, noteWidth, noteHeight, 0, 180); graphics.DrawArc(myPen, x, y, noteWidth, noteHeight, 180, 180); graphics.FillPie(myBrush, x, y, noteWidth, noteHeight, 180, 180); //Дополнительные нотоносцы с верху for (int addNN = 0; addNN < ((shiftFistNote - note + 1) / 2); addNN++) { graphics.DrawLine(myPen, x - 10, yStart - addNN * rowHeight + j * shift, x + 25, yStart - addNN * rowHeight + j * shift ); } //Дополнительные нотоносцы с низу for (int addNN = 0; addNN < (((note + 1) - (shiftFistNote + 8)) / 2); addNN++) { graphics.DrawLine(myPen, x - 10, yStart + addNN * rowHeight + j * shift + 5 * rowHeight, x + 25, yStart + addNN * rowHeight + j * shift + 5 * rowHeight ); } int xFlag = xStart + i * noteStep + fistNoteShift + 1; int yFlag = yStart //Поле + noteShift //Сдвиг ноты относительно нотоносца + j * shift //Номер ряда нотоносцев + (((note - shiftFistNote) * rowHeight) / 2); //Номер ноты graphics.DrawLine(myPen, xFlag + (needShift ? noteWidth / 2 : noteWidth), yFlag + noteHeight / 2, xFlag + (needShift ? noteWidth / 2 : noteWidth), yFlag - 40); } } } } myPen.Dispose(); myBrush.Dispose(); }
public void NaiveBayesConstructorTest5() { const int classes = 2; const int inputCount = 3; double[] classPriors = { 0.4, 0.6 }; var inputPriors = new[,] { {new UniformDiscreteDistribution(0,10), new UniformDiscreteDistribution(0,10), new UniformDiscreteDistribution(0,10)}, {new UniformDiscreteDistribution(0,10), new UniformDiscreteDistribution(0,10), new UniformDiscreteDistribution(0,10)} }; var target = new NaiveBayes<UniformDiscreteDistribution>(classes, inputCount, inputPriors, classPriors); Assert.AreEqual(classes, target.ClassCount); Assert.AreEqual(inputCount, target.InputCount); Assert.AreEqual(classPriors.Length, target.Priors.Length); Assert.AreEqual(0.4, target.Priors[0]); Assert.AreEqual(0.6, target.Priors[1]); Assert.AreEqual(2, target.Distributions.GetLength(0)); Assert.AreEqual(3, target.Distributions.GetLength(1)); }
public void SaveStoreModel() { Accord.Save(Store.DisplayName); }
public void LoadStoreModel() { Accord.Load(Store.DisplayName); }
public SerializableHmm(string actName, HiddenMarkovModel<MultivariateNormalDistribution> hmm, Accord.Statistics.Analysis.PrincipalComponentAnalysis pca) { this.pca = pca; this.name = actName; construct(hmm); }
private void audioDevice_NewFrame(object sender, Accord.Audio.NewFrameEventArgs e) { lock (syncObj) // Save the frame to the video file. { if (IsRecording) { videoWriter.WriteAudioFrame(e.Signal.RawData); } } }
public void Update(Accord accord) { db.Entry(accord).State = EntityState.Modified; }