machinelearning icon indicating copy to clipboard operation
machinelearning copied to clipboard

Issue changing model from TaxiFareExample. 'Features' must be a known-size vector of R4, but has type: Vec<I4, 2>.

Open bsexton opened this issue 8 years ago • 9 comments

System information

Issue changing model from TaxiFareExample. 'Features' must be a known-size vector of R4, but has type: Vec<I4, 2>.

  • OS version/distro: Windows
  • .NET Version (eg., dotnet --info): 4.6.1

Issue

  • What did you do? I started with the TaxiFare Example and that works. But then I changed the model and added my own values and my data. I got the error about the "Features" above. I played with it for a while and tried limiting my data. Even tried predicting the Fare Amount again.
  • What happened?
  • What did you expect?

Source code / logs

Please paste or attach the code or logs or traces that would be helpful to diagnose the issue you are reporting.

bsexton avatar Jul 13 '18 20:07 bsexton

@bsexton thanks for your question!

This is a good example of an error message that actually makes perfect sense :) The trainer expects float features, but it's given integer features instead.

The correct way to address it is either to convert the features column to float using ColumnTypeConverter, or to make your original features floats instead of ints.

The names I4 and R4 means int and float for the purposes of our data view type system. Please see the extensive type system doc for full insight into the type system. It is a long read, but it'll answer many further questions.

Zruty0 avatar Jul 18 '18 20:07 Zruty0

@Zruty0 Thanks!

I originally had all ints (which is what I really want). But there I get this error. Is it saying that it can't predict ints, only floats? "ArgumentOutOfRangeException: Training label column 'Label' type isn't suitable for regression: I4. Type must be R4 or R8. Parameter name: data"

bsexton avatar Jul 18 '18 21:07 bsexton

This is right, regression models only predict floats or doubles.

Zruty0 avatar Jul 18 '18 23:07 Zruty0

@Zruty0 Thanks again. Unfortunately I switch the column type to a float and add float values to the CSV and still get an error.

ArgumentOutOfRangeException: Training feature column 'Features' must be a known-size vector of R4, but has type: Vec<I4, 2>.

bsexton avatar Jul 18 '18 23:07 bsexton

This doesn't seem right to me. Would you mind sharing a relevant piece of the code? I'm interested in the class definition (the one that has fields with [Column] attribute), and the pipeline construction.

Zruty0 avatar Jul 19 '18 00:07 Zruty0

I am going to try breaking down the Pipeline constructor. Right now I am using the example and it isn't clear where it breaks.

I will get some code here after that.

bsexton avatar Jul 19 '18 01:07 bsexton

I am also getting the similar issue -

ArgumentOutOfRangeException: Training feature column 'Features' must be a known-size vector of R4, but has type: Vec<R8, 17>

I am using all 16 properties as double and one string. I was trying this demo solution with this dataset. The exception comes in step 5 -> pipeline.Train()

koder101 avatar Aug 22 '18 10:08 koder101

Finally, I got the solution. Posted here.

koder101 avatar Aug 22 '18 12:08 koder101

DRI RESPONSE: I considering this issue as answered and intent to close it within next few day, unless someone objects.

Ivanidzo4ka avatar Oct 19 '18 00:10 Ivanidzo4ka