-
Notifications
You must be signed in to change notification settings - Fork 103
Open
Description
Hi Seth,
Had an idea to do a REALLY simple attempt to learn a function that I would have ordinarily implemented as a switch statement, just for the mind-bending. :-)
The code was written to be run in LinqPad.
void Main()
{
Assembly.GetAssembly(typeof(Learner)).Dump();
var gen = new numl.Supervised.NeuralNetwork.NeuralNetworkGenerator();
gen.Descriptor = Descriptor.Create<WindDirection>();
var learned = Learner.Learn(WindDirection.TrainingData(), 16/20, 1, gen);
var model = learned.Model;
var accuracy = learned.Accuracy.Dump();
var windDir = new WindDirection(350, null);
model.Predict(windDir); //Uncomment this if you are running this in LinqPad .Dump("Prediction");
}
// Define other methods and classes here
public class WindDirection {
[Feature]
public double Degrees { get; set; }
[StringLabel()]
public String Direction { get; set; }
public WindDirection(double degrees, string direction)
{
this.Degrees = degrees;
this.Direction = direction;
}
public static WindDirection[] TrainingData()
{
return new[] {
// Training Values
new WindDirection(0, "N" ),
new WindDirection(22.5, "NNE"),
new WindDirection(45, "NE" ),
new WindDirection(67.5, "ENE"),
new WindDirection(90, "E" ),
new WindDirection(112.5, "ESE"),
new WindDirection(135, "SE" ),
new WindDirection(157.5, "SSE"),
new WindDirection(180, "S" ),
new WindDirection(202.5, "SSW"),
new WindDirection(225, "SW" ),
new WindDirection(247.5, "WSW"),
new WindDirection(270, "W" ),
new WindDirection(292.5, "WNW"),
new WindDirection(315, "NW" ),
new WindDirection(337.5, "NNW"),
// Testing Values
new WindDirection(22.5, "NNE"),
new WindDirection(112.5, "ESE"),
new WindDirection(11.25, "N"),
new WindDirection(359-11.25, "N")
};
}
}However, running the above Main function results in the following IndexOutOfRangeException.
at numl.Model.StringProperty.Convert(Double val) in c:\projects\numl\numl\Model\StringProperty.cs:line 109
at numl.Learner.GenerateModel(IGenerator generator, Matrix x, Vector y, IEnumerable`1 examples, Double trainingPct) in c:\projects\numl\numl\Learner.cs:line 169
at numl.Learner.<>c__DisplayClasse.<Learn>b__d(Int32 i) in c:\projects\numl\numl\Learner.cs:line 110
at System.Threading.Tasks.Parallel.<>c__DisplayClassf`1.<ForWorker>b__c()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c__DisplayClass11.<ExecuteSelfReplicating>b__10(Object param0)
I have looked at the relevant files here and I can't find the cause of the exception at the relevant lines.
I am using the NuGet 0.8.17.0 build when I am getting this exception.
Have I failed to follow the documentation correctly?
Thoughts?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels