/// <summary>
 /// save strict result object to JSON file (MultiAprioriResult)
 /// </summary>
 /// <param name="res"></param>
 /// <param name="pretty"></param>
 public SimpleJsonSaver(Ceka.Algorithms.Associaters.MultithreadedApriori.NestedFastAprioriResult res, bool pretty = false)
 {
     if (!pretty)
         this.value = JsonConvert.SerializeObject(res);
     else
         this.value = JsonConvert.SerializeObject(res, Formatting.Indented);
 }
 /// <summary>
 /// save strict result object to JSON file (SVMResult)
 /// </summary>
 /// <param name="res"></param>
 /// <param name="pretty"></param>
 public SimpleJsonSaver(Ceka.Algorithms.Classifiers.SupportVectorMachine.NestedSVMResult res, bool pretty = false)
 {
     if (!pretty)
         this.value = JsonConvert.SerializeObject(res);
     else
         this.value = JsonConvert.SerializeObject(res, Formatting.Indented);
 }
 /// <summary>
 /// save strict result object to JSON file (KMeansResult)
 /// </summary>
 /// <param name="res"></param>
 /// <param name="pretty"></param>
 public SimpleJsonSaver(Ceka.Algorithms.Clusterers.KMeans.NestedKMeansResult res, bool pretty = false)
 {
     if (!pretty)
         this.value = JsonConvert.SerializeObject(res);
     else
         this.value = JsonConvert.SerializeObject(res, Formatting.Indented);
 }
        /// <summary>
        /// trys to mimic the output of Weka's Associator Rule Results (humanreadable) - AprioriResult
        /// </summary>
        /// <param name="result"></param>
        public WekaAssociationRulesSaver(Ceka.Algorithms.Associaters.Apriori.NestedAprioriResult result)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("=== Run information === \n\n");
            sb.Append("Scheme: Ceka.Algorithms.Associators.Apriori \n");
            sb.Append("Minimum Support Filter Active: ");
            sb.Append(result.SupportApplied);
            sb.Append("\n");
            sb.Append("Confidence Filter Active: ");
            sb.Append(result.ConfidenceApplied);
            sb.Append("\n");
            sb.Append("Relation: ");
            sb.Append(result.Relation);
            sb.Append("\n");
            sb.Append("Instances: ");
            sb.Append(result.TotalDatasets);
            sb.Append("\n");
            sb.Append("Attributes: ");
            sb.Append(result.Attributes.Count);
            sb.Append("\n");

            foreach (string s in result.Attributes)
            {
                sb.Append("\t");
                sb.Append(s);
                sb.Append("\n");
            }

            sb.Append("Attributes of Value: ");
            sb.Append(result.ItemTable.Count);
            sb.Append("\n");

            foreach (List<object> at in result.ItemTable)
            {
                sb.Append("\t");
                foreach (object o in at)
                {
                    sb.Append(o);
                    sb.Append(" ");
                }
                sb.Append("\n");
            }
            sb.Append("=== Associator model (full training set) ===\n\n\n");
            sb.Append("Apriori\n=======\n\n");
            sb.Append("Minimum support: ");
            sb.Append(result.MinimumSupport);
            sb.Append(" (");
            sb.Append((int)(result.TotalDatasets * result.MinimumSupport));
            sb.Append(" instances)\n");
            sb.Append("Minimum metric <confidence>: ");
            sb.Append(result.Confidence);
            sb.Append("\nNumber of cycles performed: ");
            sb.Append(result.CyclesRan);
            sb.Append("\n\nGenerated sets of large itemsets:\n\n");

            int lloc = 1;
            foreach (List<List<object>> ds in result.CycleResults)
            {
                sb.Append("Size of set of large itemsets L(");
                sb.Append(lloc);
                sb.Append("): ");
                sb.Append(ds.Count);
                sb.Append("\n\n");
                lloc++;
            }

            sb.Append("Best rules found:\n\n");

            int line = 1;
            for (int i = result.CycleResults.Count - 1; i >= 0; i--)
            {
                foreach (List<object> dsl in result.CycleResults[i])
                {
                    sb.Append(line);
                    sb.Append(". ");

                    for (int d = 0; d < dsl.Count - 2; d++)
                    {
                        sb.Append(dsl[d]);
                        sb.Append(" ");

                        if (d == dsl.Count -4)
                            sb.Append("==> ");
                    }

                    sb.Append(" conf:(");
                    sb.Append(float.Parse(dsl[dsl.Count - 1].ToString()) / 1000);
                    sb.Append(")\n");

                    line++;
                    //dsl[dsl.Count - 1] = confidence
                    //dsl[dsl.Count - 2] = support
                }
            }

            this.value = sb.ToString();
        }