问题
I am following the Iris tutorial for ML.Net, I typed out the instructions instead of copy/pasting them so I could learn the API better, but now I am getting some errors.
When I run this line from the tutorial a System.Reflection.TargetInvocationException
is thrown:
var model = pipeline.Train<IrisData, IrisPrediction>();
The console errors I am getting during runtime are:
Bad value at line 2 in column Label
...
Bad value at line 8 in column Label
Suppressing further bad value messages
...
Processed 150 rows with 150 bad values and 0 format errors
Warning: Term map for output column 'Label' contains no entries.
Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off.
Using 2 threads to train.
Automatically choosing a check frequency of 2.
Bad value at line 1 in column Label
...
Suppressing further bad value messages
Processed 150 rows with 150 bad values and 0 format errors
Warning: Skipped 150 instances with missing features/label during training
Here is my IrisData
class:
namespace Ronald.A.Fisher
{
public class IrisData
{
[Column("0")]
public float SepalLength;
[Column("1")]
public float SepalWidth;
[Column("2")]
public float PetalLength;
[Column("3")]
public float PetalWidth;
[Column("4")]
[ColumnName("Label")]
public float Label;
}
回答1:
After looking at it for a short while I realized that one of my columns had the incorrect data type.
In the class used to load the learning data, IrisData
, I used the incorrect data type for Label
. Hence the console message: Bad value at line 1 in column Label
.
To fix this, I changed the data type for the Label
field from float
to string
:
public class IrisData
{
...
[ColumnName("Label")]
public string Label;
}
来源:https://stackoverflow.com/questions/50244255/ml-net-bad-value-at-line-1-in-column-label