/// <summary> /// Добавление модели /// </summary> public void AddModel(Vector[] vec, string name) { Vector[] vectors = vec; Vector[] components = new Vector[vectors[0].N]; SModel sMode = new SModel { NameClass = name }; for (int i = 0; i < components.Length; i++) { components[i] = new Vector(vectors.Length); for (int j = 0; j < vectors.Length; j++) { components[i].DataInVector[j] = vectors[j].DataInVector[i]; } sMode.Add(new SModelComponent(Statistic.ExpectedValue(components[i]), Statistic.Std(components[i]))); } sMode.Weights = new Vector(sMode.Count) + 0.0001; models.Add(sMode); }
/// <summary> /// Распознавание вектора /// </summary> /// <param name="inp">Вектор</param> /// <returns>Имя класса</returns> public string RecognizeVector(Vector inp) { Vector input = inp; SModel model = Output(input); return(model.Probability >= Threshold ? model.NameClass : "none"); }
/// <summary> /// Вероятности принадлежности к классу /// </summary> /// <param name="vect"></param> /// <param name="sm"></param> void GetProbability(double[] vect, SModel sm) { for (int i = 0; i < vect.Length; i++) { sm[i].pr = DistributionFunc.GaussNorm1(vect[i], sm[i]._e, sm[i]._sco); } sm.CalculateProb(); }
private Vector GW(SModel model1, SModel model2) { Vector w = new Vector(model1.Count); for (int i = 0; i < model1.Count; i++) { w[i] = Math.Abs(model1[i]._e - model2[i]._e); } return(w); }
/// <summary> /// Добавление модели /// </summary> public void AddModel(Vector[] vectors, string name) { Vector[] components = new Vector[vectors[0].N]; SModel sMode = new SModel(); sMode.NameClass = name; for (int i = 0; i < components.Length; i++) { components[i] = new Vector(vectors.Length); for (int j = 0; j < vectors.Length; j++) { components[i].Vecktor[j] = vectors[j].Vecktor[i]; } sMode.Add(new SModelComponent(Statistic.ExpectedValue(components[i]), Statistic.Sco(components[i]))); } models.Add(sMode); }
/// <summary> /// Распознавание вектора /// </summary> /// <param name="inp">Вектор</param> /// <returns>Имя класса</returns> public string RecognizeVector(Vector inp) { SModel model = Output(inp); return(model.Probability >= Porog ? model.NameClass : "none"); }