public void StartMe() { if (!IsRunning) { Gini.Start(); IsRunning = true; } }
public GiniService() { if (!IsRunning) { Gini.Start(); IsRunning = true; } }
public static BotUser GetEmp(AprajitaRetailsContext db, int empId) { if (!BotGini.IsGiniRunning()) { Gini.Start(); } BotUser emp = db.TelegramAuthUsers.Where(c => c.EmployeeId == empId).Select(c => new BotUser { MobileNo = c.MobileNo, ChatId = c.TelegramChatId }).FirstOrDefault(); return(emp); }
public static BotUser GetEmp(AprajitaRetailsContext db, int staffId, bool IsStaffId) { if (!BotGini.IsGiniRunning()) { Gini.Start(); } string StaffName = db.Salesmen.Find(staffId).SalesmanName; BotUser emp = db.TelegramAuthUsers.Where(c => c.TelegramUserName == StaffName).Select(c => new BotUser { MobileNo = c.MobileNo, ChatId = c.TelegramChatId, StaffName = c.TelegramUserName }).FirstOrDefault(); if (emp == null) { emp = new BotUser { StaffName = StaffName }; } return(emp); }
public void StopMe() { Gini.Stop(); IsRunning = false; }
private Node BuildTree(Matrix x, Vector y, int depth, List <int> used) { // reached depth limit or all labels are the same if (depth < 0 || y.Distinct().Count() == 1) { return new Node { IsLeaf = true, Label = y.Mode() } } ; double bestGain = -1; int bestFeature = -1; double[] splitValues = new double[] { }; Impurity measure = null; for (int i = 0; i < x.Cols; i++) { var feature = x[i, VectorType.Column]; var fd = Description.Features[i]; // is feature discrete? ie enum or bool? var discrete = fd.Type.IsEnum || fd.Type == typeof(bool); switch (Type) { case ImpurityType.Error: if (!discrete) { measure = Error.Of(y) .Given(feature) .WithWidth(Width); } else { measure = Error.Of(y) .Given(feature); } break; case ImpurityType.Entropy: if (!discrete) { measure = Entropy.Of(y) .Given(feature) .WithWidth(Width); } else { measure = Entropy.Of(y) .Given(feature); } break; case ImpurityType.Gini: if (!discrete) { measure = Gini.Of(y) .Given(feature) .WithWidth(Width); } else { measure = Gini.Of(y) .Given(feature); } break; } double gain = measure.RelativeGain(); if (gain > bestGain && !used.Contains(i)) { bestGain = gain; bestFeature = i; splitValues = measure.SplitValues; } } // uh oh, need to return something? // a weird node of some sort... // but just in case... if (bestFeature == -1) { return new Node { IsLeaf = true, Label = y.Mode() } } ; used.Add(bestFeature); Node n = new Node(); n.Gain = bestGain; // measure has a width property set // meaning its a continuous var // (second conditional indicates // a width that has range values) var bestFD = Description.Features[bestFeature]; // multiway split - constant fan-out width (non-continuous) if (bestFD.Type.IsEnum || bestFD.Type == typeof(bool)) { n.Children = new Node[splitValues.Length]; for (int i = 0; i < n.Children.Length; i++) { var slice = x.Indices(v => v[bestFeature] == splitValues[i], VectorType.Row); n.Children[i] = BuildTree(x.Slice(slice, VectorType.Row), y.Slice(slice), depth - 1, used); } n.Segmented = false; } // continuous split with built in ranges else { // since this is in ranges, need each slot // represents two boundaries n.Children = new Node[measure.Width]; for (int i = 0; i < n.Children.Length; i++) { var slice = x.Indices( v => v[bestFeature] >= splitValues[i] && v[bestFeature] < splitValues[i + 1], VectorType.Row); n.Children[i] = BuildTree(x.Slice(slice, VectorType.Row), y.Slice(slice), depth - 1, used); } n.Segmented = true; } n.IsLeaf = false; n.Feature = bestFeature; n.Values = splitValues; return(n); }