예제 #1
0
        public override void SaveSummary(TextWriter writer, RoleMappedSchema schema)
        {
            Host.CheckValue(writer, nameof(writer));
            Host.CheckValue(schema, nameof(schema));

            // REVIEW: Would be nice to have the settings!
            var weights = Weight;

            writer.WriteLine(LinearPredictorUtils.LinearModelAsText("Poisson Regression Predictor", null, null,
                                                                    ref weights, Bias, schema, null));
        }
예제 #2
0
        ///<inheritdoc/>
        public IList <KeyValuePair <string, object> > GetSummaryInKeyValuePairs(RoleMappedSchema schema)
        {
            Host.CheckValue(schema, nameof(schema));

            var weights = Weight;
            List <KeyValuePair <string, object> > results = new List <KeyValuePair <string, object> >();

            LinearPredictorUtils.SaveLinearModelWeightsInKeyValuePairs(ref weights, Bias, schema, results);

            return(results);
        }
예제 #3
0
        public override void SaveAsIni(TextWriter writer, RoleMappedSchema schema, ICalibrator calibrator = null)
        {
            Host.CheckValue(writer, nameof(writer));
            Host.CheckValue(schema, nameof(schema));
            Host.CheckValueOrNull(calibrator);

            var weights = Weight;

            writer.Write(LinearPredictorUtils.LinearModelAsIni(ref weights, Bias, this,
                                                               schema, calibrator as PlattCalibrator));
        }
예제 #4
0
        public override void SaveSummary(TextWriter writer, RoleMappedSchema schema)
        {
            Host.CheckValue(schema, nameof(schema));

            // REVIEW: Would be nice to have the settings!
            var weights = Weight;

            writer.WriteLine(LinearPredictorUtils.LinearModelAsText("Linear Binary Classification Predictor", null, null,
                                                                    ref weights, Bias, schema));

            _stats?.SaveText(writer, this, schema, 20);
        }
예제 #5
0
        /// <summary>
        /// Output the INI model to a given writer
        /// </summary>
        public override void SaveAsIni(TextWriter writer, RoleMappedSchema schema, ICalibrator calibrator)
        {
            if (calibrator != null)
            {
                throw Host.ExceptNotImpl("Saving calibrators is not implemented yet.");
            }

            Host.CheckValue(writer, nameof(writer));
            Host.CheckValue(schema, nameof(schema));

            // REVIEW: For Poisson should encode the exp operation in the ini as well, bug 2433.
            var weights = Weight;

            writer.Write(LinearPredictorUtils.LinearModelAsIni(ref weights, Bias, this, schema, null));
        }
예제 #6
0
        /// <summary>
        /// Output the text model to a given writer
        /// </summary>
        public void SaveAsCode(TextWriter writer, RoleMappedSchema schema)
        {
            Host.CheckValue(writer, nameof(writer));
            Host.CheckValueOrNull(schema);

            for (int i = 0; i < _biases.Length; i++)
            {
                LinearPredictorUtils.SaveAsCode(writer,
                                                ref _weights[i],
                                                _biases[i],
                                                schema,
                                                "score[" + i.ToString() + "]");
            }

            writer.WriteLine(string.Format("var softmax = MathUtils.SoftMax(scores, {0});", _numClasses));
            for (int c = 0; c < _biases.Length; c++)
            {
                writer.WriteLine("output[{0}] = Math.Exp(scores[{0}] - softmax);", c);
            }
        }