Write() public méthode

Write the specified string.
public Write ( String str ) : void
str String The string to write.
Résultat void
        /// <inheritdoc/>
        public void Save(Stream os, Object obj)
        {
            EncogWriteHelper o = new EncogWriteHelper(os);
            BayesianNetwork b = (BayesianNetwork)obj;
            o.AddSection("BAYES-NETWORK");
            o.AddSubSection("BAYES-PARAM");
            String queryType = "";
            String queryStr = b.ClassificationStructure;

            if (b.Query != null)
            {
                queryType = b.Query.GetType().Name;
            }

            o.WriteProperty("queryType", queryType);
            o.WriteProperty("query", queryStr);
            o.WriteProperty("contents", b.Contents);
            o.AddSubSection("BAYES-PROPERTIES");
            o.AddProperties(b.Properties);

            o.AddSubSection("BAYES-TABLE");
            foreach (BayesianEvent e in b.Events)
            {
                foreach (TableLine line in e.Table.Lines)
                {
                    if (line == null)
                        continue;
                    StringBuilder str = new StringBuilder();
                    str.Append("P(");

                    str.Append(BayesianEvent.FormatEventName(e, line.Result));

                    if (e.Parents.Count > 0)
                    {
                        str.Append("|");
                    }

                    int index = 0;
                    bool first = true;
                    foreach (BayesianEvent parentEvent in e.Parents)
                    {
                        if (!first)
                        {
                            str.Append(",");
                        }
                        first = false;
                        int arg = line.Arguments[index++];
                        if (parentEvent.IsBoolean)
                        {
                            if (arg == 0)
                            {
                                str.Append("+");
                            }
                            else
                            {
                                str.Append("-");
                            }
                        }
                        str.Append(parentEvent.Label);
                        if (!parentEvent.IsBoolean)
                        {
                            str.Append("=");
                            if (arg >= parentEvent.Choices.Count)
                            {
                                throw new BayesianError("Argument value " + arg + " is out of range for event " + parentEvent.ToString());
                            }
                            str.Append(parentEvent.GetChoice(arg));
                        }
                    }
                    str.Append(")=");
                    str.Append(line.Probability);
                    str.Append("\n");
                    o.Write(str.ToString());
                }
            }

            o.Flush();
        }
        /// <inheritdoc/>
        public void Save(Stream os, Object obj)
        {
            var xout = new EncogWriteHelper(os);
            var svm2 = (SupportVectorMachine) obj;
            xout.AddSection("SVM");
            xout.AddSubSection("PARAMS");
            xout.AddProperties(svm2.Properties);
            xout.AddSubSection("SVM-PARAM");
            xout.WriteProperty(PersistConst.InputCount, svm2.InputCount);
            xout.WriteProperty(ParamC, svm2.Params.C);
            xout.WriteProperty(ParamCacheSize,
                               svm2.Params.cache_size);
            xout.WriteProperty(ParamCoef0, svm2.Params.coef0);
            xout.WriteProperty(ParamDegree, svm2.Params.degree);
            xout.WriteProperty(ParamEps, svm2.Params.eps);
            xout.WriteProperty(ParamGamma, svm2.Params.gamma);
            xout.WriteProperty(ParamKernelType,
                               svm2.Params.kernel_type);
            xout.WriteProperty(ParamNumWeight,
                               svm2.Params.nr_weight);
            xout.WriteProperty(ParamNu, svm2.Params.nu);
            xout.WriteProperty(ParamP, svm2.Params.p);
            xout.WriteProperty(ParamProbability,
                               svm2.Params.probability);
            xout.WriteProperty(ParamShrinking,
                               svm2.Params.shrinking);
            /* xout.WriteProperty(PersistSVM.PARAM_START_ITERATIONS,
                    svm2.Params.statIterations); */
            xout.WriteProperty(ParamSVMType, svm2.Params.svm_type);
            xout.WriteProperty(ParamWeight, svm2.Params.weight);
            xout.WriteProperty(ParamWeightLabel,
                               svm2.Params.weight_label);
            if (svm2.Model != null)
            {
                xout.AddSubSection("SVM-MODEL");
                try
                {
                    var ba = new MemoryStream();
                    var w = new StreamWriter(ba);
                    svm.svm_save_model(w, svm2.Model);
                    var enc = new ASCIIEncoding();
                    xout.Write(enc.GetString(ba.ToArray()));
                    w.Close();
                    ba.Close();
                }
                catch (IOException ex)
                {
                    throw new PersistError(ex);
                }
            }

            xout.Flush();
        }
Exemple #3
0
 public void Save(Stream os, object obj)
 {
     SupportVectorMachine machine;
     EncogWriteHelper helper = new EncogWriteHelper(os);
     if (8 != 0)
     {
     }
     Label_026A:
     machine = (SupportVectorMachine) obj;
     helper.AddSection("SVM");
     if (0 == 0)
     {
         while (true)
         {
             helper.AddSubSection("PARAMS");
             helper.AddProperties(machine.Properties);
             helper.AddSubSection("SVM-PARAM");
             helper.WriteProperty("inputCount", machine.InputCount);
             helper.WriteProperty("C", machine.Params.C);
             if (0 == 0)
             {
                 helper.WriteProperty("cacheSize", machine.Params.cache_size);
                 if (-2 == 0)
                 {
                     goto Label_026A;
                 }
                 helper.WriteProperty("coef0", machine.Params.coef0);
                 helper.WriteProperty("degree", machine.Params.degree);
                 helper.WriteProperty("eps", machine.Params.eps);
                 helper.WriteProperty("gamma", machine.Params.gamma);
                 helper.WriteProperty("kernelType", machine.Params.kernel_type);
             }
             helper.WriteProperty("nrWeight", machine.Params.nr_weight);
             if (1 != 0)
             {
                 helper.WriteProperty("nu", machine.Params.nu);
                 helper.WriteProperty("p", machine.Params.p);
                 helper.WriteProperty("probability", machine.Params.probability);
                 helper.WriteProperty("shrinking", machine.Params.shrinking);
                 helper.WriteProperty("svmType", machine.Params.svm_type);
                 helper.WriteProperty("weight", machine.Params.weight);
                 helper.WriteProperty("weightLabel", machine.Params.weight_label);
                 break;
             }
         }
     }
     Label_0092:
     while (machine.Model != null)
     {
         helper.AddSubSection("SVM-MODEL");
         try
         {
             StreamWriter writer;
             ASCIIEncoding encoding;
             MemoryStream stream = new MemoryStream();
             if (1 != 0)
             {
                 goto Label_005F;
             }
         Label_003E:
             helper.Write(encoding.GetString(stream.ToArray()));
             writer.Close();
             stream.Close();
             break;
         Label_005F:
             writer = new StreamWriter(stream);
             if (0 == 0)
             {
                 svm.svm_save_model(writer, machine.Model);
             }
             encoding = new ASCIIEncoding();
             goto Label_003E;
         }
         catch (IOException exception)
         {
             throw new PersistError(exception);
         }
     }
     while (true)
     {
         helper.Flush();
         if (-2147483648 != 0)
         {
             return;
         }
         if (0 != 0)
         {
             goto Label_0092;
         }
     }
 }