/// <summary>
        /// Initializes a new instance of the <see cref="BayesPointMachineClassifierTrainingSettings"/> class.
        /// </summary>
        /// <param name="isTrained">Indicates whether the Bayes point machine classifier is trained.</param>
        internal BayesPointMachineClassifierTrainingSettings(Func <bool> isTrained)
        {
            this.trainingSettingsGuard = new SettingsGuard(isTrained, "This setting cannot be changed after training.");

            this.computeModelEvidence = ComputeModelEvidenceDefault;
            this.iterationCount       = IterationCountDefault;
            this.batchCount           = BatchCountDefault;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MatchboxRecommenderAdvancedTrainingSettings"/> class.
        /// </summary>
        /// <param name="isTrained">Indicates whether the Matchbox recommender is trained.</param>
        internal MatchboxRecommenderAdvancedTrainingSettings(Func <bool> isTrained)
        {
            this.trainingSettingsGuard = new SettingsGuard(isTrained, "This setting cannot be changed after training.");

            this.User        = new UserHyperparameters();
            this.Item        = new ItemHyperparameters();
            this.UserFeature = new FeatureHyperparameters();
            this.ItemFeature = new FeatureHyperparameters();
            this.Noise       = new NoiseHyperparameters();
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MatchboxRecommenderTrainingSettings"/> class.
        /// </summary>
        /// <param name="isTrained">Indicates whether the Matchbox recommender is trained.</param>
        internal MatchboxRecommenderTrainingSettings(Func <bool> isTrained)
        {
            this.trainingSettingsGuard = new SettingsGuard(isTrained, "This setting cannot be changed after training.");

            this.Advanced                = new MatchboxRecommenderAdvancedTrainingSettings(isTrained);
            this.useUserFeatures         = UseUserFeaturesDefault;
            this.useItemFeatures         = UseItemFeaturesDefault;
            this.traitCount              = TraitCountDefault;
            this.batchCount              = BatchCountDefault;
            this.iterationCount          = IterationCountDefault;
            this.useSharedUserThresholds = UseSharedUserThresholdsDefault;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BayesPointMachineClassifierTrainingSettings"/> class
        /// from a reader of a binary stream.
        /// </summary>
        /// <param name="reader">The binary reader to read the training settings from.</param>
        /// <param name="isTrained">Indicates whether the Bayes point machine classifier is trained.</param>
        internal BayesPointMachineClassifierTrainingSettings(BinaryReader reader, Func <bool> isTrained)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            reader.VerifySerializationGuid(
                this.customSerializationGuid, "The binary stream does not contain the training settings of an Infer.NET Bayes point machine classifier.");

            int deserializedVersion = reader.ReadSerializationVersion(CustomSerializationVersion);

            if (deserializedVersion == CustomSerializationVersion)
            {
                this.trainingSettingsGuard = new SettingsGuard(reader, isTrained);

                this.computeModelEvidence = reader.ReadBoolean();
                this.iterationCount       = reader.ReadInt32();
                this.batchCount           = reader.ReadInt32();
            }
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MatchboxRecommenderTrainingSettings"/> class
        /// from a reader of a binary stream.
        /// </summary>
        /// <param name="reader">The binary reader to read the training settings from.</param>
        /// <param name="isTrained">Indicates whether the Matchbox recommender is trained.</param>
        internal MatchboxRecommenderTrainingSettings(BinaryReader reader, Func <bool> isTrained)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            reader.VerifySerializationGuid(
                this.customSerializationGuid, "The binary stream does not contain the training settings of an Infer.NET Matchbox recommender.");

            int deserializedVersion = reader.ReadSerializationVersion(CustomSerializationVersion);

            if (deserializedVersion == 1)
            {
                this.trainingSettingsGuard = new SettingsGuard(reader, isTrained);
                this.ReadVersion1(reader, isTrained);
            }
            else if (deserializedVersion == CustomSerializationVersion)
            {
                this.trainingSettingsGuard = new SettingsGuard(reader, isTrained);
                this.ReadVersion2(reader, isTrained);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MatchboxRecommenderAdvancedTrainingSettings"/> class.
        /// from a reader of a binary stream.
        /// </summary>
        /// <param name="reader">The binary reader to read the advanced training settings from.</param>
        /// <param name="isTrained">Indicates whether the Matchbox recommender is trained.</param>
        internal MatchboxRecommenderAdvancedTrainingSettings(IReader reader, Func <bool> isTrained)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            reader.VerifySerializationGuid(
                this.customSerializationGuid, "The binary stream does not contain the advanced training settings of an Infer.NET Matchbox recommender.");

            int deserializedVersion = reader.ReadSerializationVersion(CustomSerializationVersion);

            if (deserializedVersion == CustomSerializationVersion)
            {
                this.trainingSettingsGuard = new SettingsGuard(reader, isTrained);

                this.User        = new UserHyperparameters(reader);
                this.Item        = new ItemHyperparameters(reader);
                this.UserFeature = new FeatureHyperparameters(reader);
                this.ItemFeature = new FeatureHyperparameters(reader);
                this.Noise       = new NoiseHyperparameters(reader);
            }
        }