public void getSvmModel(string modelPath, bool BuildModel = false) { using (System.IO.StreamReader sr = new System.IO.StreamReader(modelPath)) { string mType = sr.ReadLine(); modelTypes m = (modelTypes)Enum.Parse(typeof(modelTypes), mType); if (m != modelTypes.SVM) { System.Windows.Forms.MessageBox.Show("Model file specified is not a DA!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } InTablePath = sr.ReadLine(); IndependentFieldNames = sr.ReadLine().Split(new char[] { ',' }); DependentFieldNames = sr.ReadLine().Split(new char[] { ',' }); ClassFieldNames = sr.ReadLine().Split(new char[] { ',' }); n = System.Convert.ToInt32(sr.ReadLine()); nvars = System.Convert.ToInt32(sr.ReadLine()); sserror = System.Convert.ToDouble(sr.ReadLine()); kTyp = (KernelType)Enum.Parse(typeof(KernelType), sr.ReadLine()); minValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); maxValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); sumValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); sr.Close(); } if (BuildModel) { string svmMPath = modelPath.Replace(".mdl", ".svm"); MulticlassSupportVectorMachine.Load(svmMPath); } }
public void getDaModel(string modelPath, bool BuildModel = false) { using (System.IO.StreamReader sr = new System.IO.StreamReader(modelPath)) { string mType = sr.ReadLine(); modelTypes m = (modelTypes)Enum.Parse(typeof(modelTypes), mType); if (m != modelTypes.LDA) { System.Windows.Forms.MessageBox.Show("Model file specified is not a DA!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } InTablePath = sr.ReadLine(); IndependentFieldNames = sr.ReadLine().Split(new char[] { ',' }); DependentFieldNames = sr.ReadLine().Split(new char[] { ',' }); ClassFieldNames = sr.ReadLine().Split(new char[] { ',' }); n = System.Convert.ToInt32(sr.ReadLine()); nvars = System.Convert.ToInt32(sr.ReadLine()); minValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); maxValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); sumValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); meanValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); stdValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); sr.Close(); } if (BuildModel) { buildModel(); } }
public void getMlrModel(string modelPath, bool BuildModel = false) { using (System.IO.StreamReader sr = new System.IO.StreamReader(modelPath)) { string mType = sr.ReadLine(); modelTypes m = (modelTypes)Enum.Parse(typeof(modelTypes), mType); if (m != modelTypes.MvlRegression) { System.Windows.Forms.MessageBox.Show("Model file specified is not a Multivariate Linear Regression Model!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } string ln = sr.ReadLine(); List <dataPrepLinearReg> lrLst = new List <dataPrepLinearReg>(); while (ln != null) { dataPrepLinearReg lr = new dataPrepLinearReg(); lr.getLrModel(ln, BuildModel); lrLst.Add(lr); ln = sr.ReadLine(); if (IndependentFieldNames == null) { IndependentFieldNames = lr.IndependentFieldNames; DependentFieldNames = lr.DependentFieldNames; ClassFieldNames = lr.ClassFieldNames; } } sr.Close(); mvr = lrLst.ToArray(); } }
public void getPlrModel(string modelPath, bool BuildModel = false) { using (System.IO.StreamReader sr = new System.IO.StreamReader(modelPath)) { string mType = sr.ReadLine(); modelTypes m = (modelTypes)Enum.Parse(typeof(modelTypes), mType); if (m != modelTypes.PLR) { System.Windows.Forms.MessageBox.Show("Model file specified is not a PLR Model!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } InTablePath = sr.ReadLine(); IndependentFieldNames = sr.ReadLine().Split(new char[] { ',' }); DependentFieldNames = sr.ReadLine().Split(new char[] { ',' }); ClassFieldNames = sr.ReadLine().Split(new char[] { ',' }); categories = sr.ReadLine().Split(new char[] { ',' }); nvars = System.Convert.ToInt32(sr.ReadLine()); ncat = System.Convert.ToInt32(sr.ReadLine()); delta = System.Convert.ToDouble(sr.ReadLine()); iteration = System.Convert.ToInt32(sr.ReadLine()); loglikelihood = System.Convert.ToDouble(sr.ReadLine()); deviance = System.Convert.ToDouble(sr.ReadLine()); x2 = System.Convert.ToDouble(sr.ReadLine()); pv = System.Convert.ToDouble(sr.ReadLine()); minValues = (from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray(); maxValues = (from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray(); sumValues = (from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray(); coefficients = new double[ncat - 1][]; standarderror = new double[ncat - 1][]; waldstat = new double[ncat - 1][]; waldpvalue = new double[ncat - 1][]; double[] vlArr = new double[nvars + 1]; for (int i = 0; i < ncat - 1; i++) { vlArr = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); coefficients[i] = vlArr; } for (int i = 0; i < ncat - 1; i++) { vlArr = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); standarderror[i] = vlArr; } for (int i = 0; i < ncat - 1; i++) { vlArr = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); waldstat[i] = vlArr; } for (int i = 0; i < ncat - 1; i++) { vlArr = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); waldpvalue[i] = vlArr; } sr.Close(); if (BuildModel) { buildModel(); } } }
public void getModel(string modelPath) { using (System.IO.StreamReader sr = new System.IO.StreamReader(modelPath)) { string mType = sr.ReadLine(); modelTypes m = (modelTypes)Enum.Parse(typeof(modelTypes), mType); if (m != modelTypes.CompareClassifications) { System.Windows.Forms.MessageBox.Show("Model file specified is not an Accuracy Assessment!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } string fieldNames = sr.ReadLine(); string[] fieldNamesSplit = fieldNames.Split(new char[] { ',' }); IndependentFieldNames = new string[] { fieldNamesSplit[1], fieldNamesSplit[2] }; DependentFieldNames = new string[] { fieldNamesSplit[0] }; ClassFieldNames = fieldNamesSplit; labels = sr.ReadLine().Split(new char[] { ',' }).ToList(); mctable = new int[2, 2]; g1table = new int[labels.Count, labels.Count]; g2table = new int[labels.Count, labels.Count]; g3table = new int[labels.Count, labels.Count]; string ln = sr.ReadLine(); int[] intArr = (from string s in ln.Split(new char[] { ',' }) select System.Convert.ToInt32(s)).ToArray(); int cnt = 0; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { mctable[i, j] = intArr[cnt]; cnt++; } } ln = sr.ReadLine(); int[] intArr1 = (from string s in ln.Split(new char[] { ',' }) select System.Convert.ToInt32(s)).ToArray(); ln = sr.ReadLine(); int[] intArr2 = (from string s in ln.Split(new char[] { ',' }) select System.Convert.ToInt32(s)).ToArray(); ln = sr.ReadLine(); int[] intArr3 = (from string s in ln.Split(new char[] { ',' }) select System.Convert.ToInt32(s)).ToArray(); cnt = 0; for (int i = 0; i < labels.Count; i++) { for (int j = 0; j < labels.Count; j++) { g1table[i, j] = intArr1[cnt]; g2table[i, j] = intArr2[cnt]; g3table[i, j] = intArr3[cnt]; cnt++; } } sr.Close(); } buildModel(); }
public alglib.logitmodel getMnlModel(string modelPath) { double[,] coef = null; using (System.IO.StreamReader sr = new System.IO.StreamReader(modelPath)) { string mType = sr.ReadLine(); modelTypes m = (modelTypes)Enum.Parse(typeof(modelTypes), mType); if (m != modelTypes.SoftMax) { System.Windows.Forms.MessageBox.Show("Model file specified is not a SoftMax Nnet Model!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return(null); } InTablePath = sr.ReadLine(); n = System.Convert.ToInt32(sr.ReadLine()); IndependentFieldNames = sr.ReadLine().Split(new char[] { ',' }); DependentFieldNames = sr.ReadLine().Split(new char[] { ',' }); ClassFieldNames = sr.ReadLine().Split(new char[] { ',' }); categories = sr.ReadLine().Split(new char[] { ',' }); nvars = System.Convert.ToInt32(sr.ReadLine()); nclasses = System.Convert.ToInt32(sr.ReadLine()); rmse = System.Convert.ToDouble(sr.ReadLine()); avgcee = System.Convert.ToDouble(sr.ReadLine()); avge = System.Convert.ToDouble(sr.ReadLine()); avgre = System.Convert.ToDouble(sr.ReadLine()); clse = System.Convert.ToDouble(sr.ReadLine()); rce = System.Convert.ToDouble(sr.ReadLine()); minValues = (from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray(); maxValues = (from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray(); sumValues = (from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray(); coef = new double[nclasses - 1, nvars + 1]; string ln = sr.ReadLine(); int lnCnt = 0; while (ln != null) { string[] lnArr = ln.Split(new char[] { ' ' }); for (int i = 0; i < lnArr.Length; i++) { coef[i, lnCnt] = System.Convert.ToDouble(lnArr[i]); } lnCnt += 1; ln = sr.ReadLine(); } sr.Close(); } alglib.mnlpack(coef, nvars, nclasses, out lm); return(lm); }
public void SwitchToMale(bool reset = false) { if (!_maleModel || reset) { _maleModel = Instantiate(m_MalePrefab); _maleModel.transform.position = m_SpawnPosition; } if (_currentSpawnedModel) { _currentSpawnedModel.SetActive(false); } _maleModel.SetActive(true); _currentSpawnedModel = _maleModel; _currentModelType = modelTypes.male; UpdateHighlightJoints(); }
public void getLrModel(string modelPath, bool BuildModel = false) { using (System.IO.StreamReader sr = new System.IO.StreamReader(modelPath)) { string mType = sr.ReadLine(); modelTypes m = (modelTypes)Enum.Parse(typeof(modelTypes), mType); if (m != modelTypes.LogisticRegression) { System.Windows.Forms.MessageBox.Show("Model file specified is not a Logistic Regression Model!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } InTablePath = sr.ReadLine(); IndependentFieldNames = sr.ReadLine().Split(new char[] { ',' }); DependentFieldNames = sr.ReadLine().Split(new char[] { ',' }); ClassFieldNames = sr.ReadLine().Split(new char[] { ',' }); categories = sr.ReadLine().Split(new char[] { ',' }); nvars = System.Convert.ToInt32(sr.ReadLine()); ncat = System.Convert.ToInt32(sr.ReadLine()); loglikelihood = System.Convert.ToDouble(sr.ReadLine()); deviance = System.Convert.ToDouble(sr.ReadLine()); x2 = System.Convert.ToDouble(sr.ReadLine()); pv = System.Convert.ToDouble(sr.ReadLine()); minValues = (from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray(); maxValues = (from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray(); sumValues = (from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray(); coefficients = (from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray(); standarderror = (from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray(); waldstat = new Accord.Statistics.Testing.WaldTest[coefficients.Length]; double[] waldStatVl = (from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray(); double[] waldStatPVl = (from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray(); for (int i = 0; i < waldStatVl.Length; i++) { double wVl = waldStatVl[i]; Accord.Statistics.Testing.WaldTest wt = new Accord.Statistics.Testing.WaldTest(wVl); waldstat[i] = wt; } sr.Close(); if (BuildModel) { buildModel(); } } }
public void getLrModel(string modelPath, bool BuildModel = false) { using (System.IO.StreamReader sr = new System.IO.StreamReader(modelPath)) { string mType = sr.ReadLine(); modelTypes m = (modelTypes)Enum.Parse(typeof(modelTypes), mType); if (m != modelTypes.LinearRegression) { System.Windows.Forms.MessageBox.Show("Model file specified is not a Linear Regression Model!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } InTablePath = sr.ReadLine(); IndependentFieldNames = sr.ReadLine().Split(new char[] { ',' }); DependentFieldNames = sr.ReadLine().Split(new char[] { ',' }); ClassFieldNames = sr.ReadLine().Split(new char[] { ',' }); n = System.Convert.ToInt32(sr.ReadLine()); nvars = System.Convert.ToInt32(sr.ReadLine()); string vl = sr.ReadLine(); if (vl.ToLower() == "false") { intOrigin = false; } else { intOrigin = true; } rmse = System.Convert.ToDouble(sr.ReadLine()); ftest = System.Convert.ToDouble(sr.ReadLine()); pv = System.Convert.ToDouble(sr.ReadLine()); r2 = System.Convert.ToDouble(sr.ReadLine()); ar2 = System.Convert.ToDouble(sr.ReadLine()); coefficients = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); standarderrors = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); minValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); maxValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); sumValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); sr.Close(); } if (BuildModel) { buildModel(); } }
public void getXTable(string modelPath) { using (System.IO.StreamReader sr = new System.IO.StreamReader(modelPath)) { string mType = sr.ReadLine(); modelTypes m = (modelTypes)Enum.Parse(typeof(modelTypes), mType); if (m != modelTypes.Accuracy) { System.Windows.Forms.MessageBox.Show("Model file specified is not an Accuracy Assessment!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } string fieldNames = sr.ReadLine(); string[] fieldNamesSplit = fieldNames.Split(new char[] { ',' }); IndependentFieldNames = new string[] { fieldNamesSplit[1] }; DependentFieldNames = new string[] { fieldNamesSplit[0] }; ClassFieldNames = fieldNamesSplit; labels = sr.ReadLine().Split(new char[] { ',' }).ToList(); double overall = System.Convert.ToDouble(sr.ReadLine()); double k = System.Convert.ToDouble(sr.ReadLine()); double kerr = System.Convert.ToDouble(sr.ReadLine()); xtable = new int[labels.Count, labels.Count]; string ln = sr.ReadLine(); int lnCnt = 0; while (ln != null) { string[] lnArr = ln.Split(new char[] { ' ' }); for (int i = 0; i < lnArr.Length; i++) { xtable[i, lnCnt] = System.Convert.ToInt32(lnArr[i]); } lnCnt += 1; ln = sr.ReadLine(); } sr.Close(); } buildModel(); }
public void getGlmModel(string modelPath, bool BuildModel = false) { using (System.IO.StreamReader sr = new System.IO.StreamReader(modelPath)) { string mType = sr.ReadLine(); modelTypes m = (modelTypes)Enum.Parse(typeof(modelTypes), mType); if (m != modelTypes.GLM) { System.Windows.Forms.MessageBox.Show("Model file specified is not a GLM!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } InTablePath = sr.ReadLine(); IndependentFieldNames = sr.ReadLine().Split(new char[] { ',' }); DependentFieldNames = sr.ReadLine().Split(new char[] { ',' }); ClassFieldNames = sr.ReadLine().Split(new char[] { ',' }); n = System.Convert.ToInt32(sr.ReadLine()); nvars = System.Convert.ToInt32(sr.ReadLine()); iterations = System.Convert.ToInt32(sr.ReadLine()); delta = System.Convert.ToDouble(sr.ReadLine()); loglikelihood = System.Convert.ToDouble(sr.ReadLine()); loglikelihoodratio = System.Convert.ToDouble(sr.ReadLine()); pv = System.Convert.ToDouble(sr.ReadLine()); deviance = System.Convert.ToDouble(sr.ReadLine()); chisqr = System.Convert.ToDouble(sr.ReadLine()); linkfunction = (LinkFunction)Enum.Parse(typeof(LinkFunction), sr.ReadLine()); coefficients = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); stdError = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); waldTestValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); waldTestPValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); minValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); maxValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); sumValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray(); sr.Close(); } if (BuildModel) { Accord.Statistics.Links.ILinkFunction lFunc = new Accord.Statistics.Links.IdentityLinkFunction(); switch (Link) { case LinkFunction.Absolute: lFunc = new Accord.Statistics.Links.AbsoluteLinkFunction(); break; case LinkFunction.Cauchit: lFunc = new Accord.Statistics.Links.CauchitLinkFunction(); break; case LinkFunction.Inverse: lFunc = new Accord.Statistics.Links.InverseLinkFunction(); break; case LinkFunction.InverseSquared: lFunc = new Accord.Statistics.Links.InverseSquaredLinkFunction(); break; case LinkFunction.Logit: lFunc = new Accord.Statistics.Links.LogitLinkFunction(); break; case LinkFunction.Log: lFunc = new Accord.Statistics.Links.LogLinkFunction(); break; case LinkFunction.LogLog: lFunc = new Accord.Statistics.Links.LogLogLinkFunction(); break; case LinkFunction.Probit: lFunc = new Accord.Statistics.Links.ProbitLinkFunction(); break; case LinkFunction.Sin: lFunc = new Accord.Statistics.Links.SinLinkFunction(); break; case LinkFunction.Threshold: lFunc = new Accord.Statistics.Links.ThresholdLinkFunction(); break; default: break; } glm = new Accord.Statistics.Models.Regression.GeneralizedLinearRegression(lFunc, coefficients, stdError); } }