This project is read-only.

Perceptron and LinearRegression should directly usable


The IModel and IPredict interfaces provide useful abstractions, however they hide interesting information on the supervised classes. For example, the PerceptronPredictor.W and PerceptronPredictor.Features properties help explain the predictions.

  1. Expose this information by making the properties more visibile
public class PerceptronPredictor<T> : IPredict<T>, IXmlSerializable
    internal Vector W { get; set; }
    internal Property[] Features { get; set; }
    internal Property Target { get; set; }
    internal double B { get; set; } 
public class PerceptronPredictor<T> : IPredict<T>, IXmlSerializable
    public Vector W { get; internal set; }
    public Property[] Features { get; internal set; }
    public Property Target { get; internal set; }
    public double B { get; internal set; }
  1. Making the PerceptronModel.Generate method static to eliminate the need to instantiate the PerceptronModel.
The current usage is
var model = new PerceptronModel<Student>();
var predictor = model.Generate(students);
If made static, this would be reduced to
var predictor = PerceptronModel<Student>.Generate(students);
  1. The PerceptronModel.Generate method should return a PerceptronPredictor, in addition to the IPredict. This will allow it to be used directly, without casting.
Existing usage
PerceptronPredictor<Student> predictor = (PerceptronPredictor<Student>)model.Generate(data);
Proposed usage
PerceptronPredictor<Student> predictor = PerceptronModel<Student>.Generate(data);
The code to make this work is:
    IPredict<T> IModel<T>.Generate(IEnumerable<T> examples)
        return Generate(examples);

    public PerceptronPredictor<T> Generate(IEnumerable<T> examples)


SethJuarez wrote Aug 20, 2010 at 7:50 PM

Sounds good. I will add them sometime this week.