public string writeModel(string outModelPath) { outPath = outModelPath; using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outPath)) { sw.WriteLine(modelTypes.LinearRegression.ToString()); sw.WriteLine(InTablePath); sw.WriteLine(String.Join(",", IndependentFieldNames)); sw.WriteLine(String.Join(",", DependentFieldNames)); sw.WriteLine(String.Join(",", ClassFieldNames)); sw.WriteLine(SampleSize.ToString()); sw.WriteLine(NumberOfVariables.ToString()); sw.WriteLine(InterceptThroughOrigin.ToString()); sw.WriteLine(RMSE); sw.WriteLine(FValue.ToString()); sw.WriteLine(PValue.ToString()); sw.WriteLine(Rsquared.ToString()); sw.WriteLine(AdjustedRsquared.ToString()); sw.WriteLine(String.Join(" ", (from double d in Coefficients select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in StandardErrors select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in minValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in maxValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in sumValues select d.ToString()).ToArray())); sw.Close(); } return(outPath); }
public string writeModel(string outModelPath) { outPath = outModelPath; string outPathSvm = outModelPath.Replace(".mdl", ".svm"); svmMachine.Save(outPathSvm); using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outPath)) { sw.WriteLine(modelTypes.SVM.ToString()); sw.WriteLine(InTablePath); sw.WriteLine(String.Join(",", IndependentFieldNames)); sw.WriteLine(String.Join(",", DependentFieldNames)); if (ClassFieldNames != null) { sw.WriteLine(String.Join(",", ClassFieldNames)); } else { sw.WriteLine(); } sw.WriteLine(SampleSize.ToString()); sw.WriteLine(NumberOfVariables.ToString()); sw.WriteLine(sserror.ToString()); sw.WriteLine(kTyp.ToString()); sw.WriteLine(String.Join(" ", (from double d in minValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in maxValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in sumValues select d.ToString()).ToArray())); sw.Close(); } return(outPath); }
public string writeModel(string outModelPath) { outPath = outModelPath; using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outPath)) { sw.WriteLine(modelTypes.GLM.ToString()); sw.WriteLine(InTablePath); sw.WriteLine(String.Join(",", IndependentFieldNames)); sw.WriteLine(String.Join(",", DependentFieldNames)); sw.WriteLine(String.Join(",", ClassFieldNames)); sw.WriteLine(SampleSize.ToString()); sw.WriteLine(NumberOfVariables.ToString()); sw.WriteLine(Iterations.ToString()); sw.WriteLine(DeltaC.ToString()); sw.WriteLine(LogLikelihood); sw.WriteLine(LogLikelihoodratio); sw.WriteLine(PValue.ToString()); sw.WriteLine(Deviance.ToString()); sw.WriteLine(ChiSquare.ToString()); sw.WriteLine(linkfunction.ToString()); sw.WriteLine(String.Join(" ", (from double d in Coefficients select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in StdError select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in waldTestValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in waldTestPValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in minValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in maxValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in sumValues select d.ToString()).ToArray())); sw.Close(); } return(outPath); }
public string writeModel(string outModelPath) { if (lm == null) { getMnlModel(); } outPath = outModelPath; double[,] coef = null; alglib.mnlunpack(lm, out coef, out nvars, out nclasses); using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outPath)) { sw.WriteLine(modelTypes.SoftMax.ToString()); sw.WriteLine(InTablePath); sw.WriteLine(SampleSize.ToString()); sw.WriteLine(String.Join(",", IndependentFieldNames)); sw.WriteLine(String.Join(",", DependentFieldNames)); sw.WriteLine(String.Join(",", ClassFieldNames)); sw.WriteLine(string.Join(",", Categories)); sw.WriteLine(NumberOfVariables.ToString()); sw.WriteLine(NumberOfClasses.ToString()); sw.WriteLine(RMSE.ToString()); sw.WriteLine(AverageCrossEntropyError.ToString()); sw.WriteLine(AverageError.ToString()); sw.WriteLine(AverageRelativeError.ToString()); sw.WriteLine(ClassificationError.ToString()); sw.WriteLine(RelativeClassificationError.ToString()); sw.WriteLine(String.Join(",", (from double d in minValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(",", (from double d in maxValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(",", (from double d in sumValues select d.ToString()).ToArray())); int rws = coef.GetUpperBound(1); int clms = coef.GetUpperBound(0); for (int r = 0; r <= rws; r++) { string[] ln = new string[clms + 1]; for (int c = 0; c <= clms; c++) { ln[c] = coef[c, r].ToString(); } sw.WriteLine(String.Join(" ", ln)); } sw.Close(); } return(outPath); }
public string writeModel(string outModelPath) { outPath = outModelPath; using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outPath)) { sw.WriteLine(modelTypes.LDA.ToString()); sw.WriteLine(InTablePath); sw.WriteLine(String.Join(",", IndependentFieldNames)); sw.WriteLine(String.Join(",", DependentFieldNames)); sw.WriteLine(String.Join(",", ClassFieldNames)); sw.WriteLine(SampleSize.ToString()); sw.WriteLine(NumberOfVariables.ToString()); sw.WriteLine(String.Join(" ", (from double d in minValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in maxValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in sumValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in meanValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in stdValues select d.ToString()).ToArray())); sw.Close(); } return(outPath); }