예제 #1
0
        /// <summary>
        /// similar to the traditional constructor with filter options, but leaves options for different result saving
        /// </summary>
        /// <param name="ai"></param>
        /// <param name="support"></param>
        /// <param name="confidence"></param>
        /// <param name="filterSupport"></param>
        /// <param name="filterConfidence"></param>
        /// <param name="savt"></param>
        public Apriori(ArffInstance ai, float support, float confidence, bool filterSupport, bool filterConfidence, Saver.AprioriSaveTypes savt, bool cli = false, string outputFile = null)
            : this(ai, support, confidence)
        {
            this.filterForSupport = filterSupport;
            this.filterForConfidence = filterConfidence;

            this.run_default_process(filterSupport, filterConfidence);

            string file = this.source.Relation + "_result";
            if (outputFile != null)
                file = outputFile;

            switch (savt)
            {
                case Saver.AprioriSaveTypes.JSON:
                    if (!cli)
                        new Saver.SimpleJsonSaver(this.get_aobj_result(), false).SaveToFile(file + ".json");
                    else
                        new Saver.SimpleJsonSaver(this.get_aobj_result(), false).CLI();
                    break;

                case Saver.AprioriSaveTypes.JSON_PRETTY:
                    if (!cli)
                        new Saver.SimpleJsonSaver(this.get_aobj_result(), true).SaveToFile(file + ".json");
                    else
                        new Saver.SimpleJsonSaver(this.get_aobj_result(), true).CLI();
                    break;

                case Saver.AprioriSaveTypes.WEKA:
                    if (!cli)
                        new Saver.WekaAssociationRulesSaver(this.get_aobj_result()).SaveToFile(file + ".ceka");
                    else
                        new Saver.WekaAssociationRulesSaver(this.get_aobj_result()).CLI();
                    break;

                case Saver.AprioriSaveTypes.NONE:
                    log("Apriori finished, doing nothing as SaveType is NONE.");
                    break;

                default:
                    log("Apriori finished, but SaveType is DEFAULT: " + savt.ToString());
                    break;
            }
        }