-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Replace DvBool with .NET standard type. #692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
{ | ||
Ch.Assert(colType.ItemType.IsBool); | ||
return CreateConvertingArrayGetterDelegate<bool?, DvBool>(index, x => x ?? DvBool.NA); | ||
return CreateConvertingArrayGetterDelegate<bool, bool>(index, x => x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool [](start = 77, length = 4)
you don't have to do it.
just fall back to default T[] -> VBuffer code. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ch.Assert(colType.IsBool); | ||
return CreateConvertingGetterDelegate<bool?, DvBool>(index, x => x ?? DvBool.NA); | ||
return CreateConvertingGetterDelegate<bool, bool>(index, x => x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return CreateConvertingGetterDelegate<bool, bool>(index, x => x); [](start = 27, length = 66)
not needed, fall back to T-> T default #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/Microsoft.ML.Api/TypedCursor.cs
Outdated
{ | ||
Ch.Assert(colType.ItemType.IsBool); | ||
return CreateConvertingVBufferSetter<DvBool, bool?>(input, index, poke, peek, x => (bool?)x); | ||
return CreateConvertingVBufferSetter<bool, bool>(input, index, poke, peek, x => x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fall back to // VBuffer -> T[] #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/Microsoft.ML.Api/TypedCursor.cs
Outdated
Ch.Assert(colType.IsBool); | ||
Ch.Assert(peek == null); | ||
return CreateConvertingActionSetter<DvBool, bool?>(input, index, poke, x => (bool?)x); | ||
return CreateConvertingActionSetter<bool, bool>(input, index, poke, x => x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CreateConvertingActionSetter [](start = 31, length = 28)
fall back to // T -> T #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -11,10 +11,11 @@ | |||
using System.Text; | |||
using System.Threading; | |||
using Microsoft.ML.Runtime.Internal.Utilities; | |||
using System.Runtime.CompilerServices; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorting #Resolved
dst.Append("0"); | ||
else if (src.IsTrue) | ||
else if (src) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (src) [](start = 17, length = 8)
this if looks redundant #Resolved
@@ -1826,8 +1821,8 @@ public void Convert(ref TX span, ref DZ value) | |||
public void Convert(ref BL src, ref I2 dst) => dst = (I2)src; | |||
public void Convert(ref BL src, ref I4 dst) => dst = (I4)src; | |||
public void Convert(ref BL src, ref I8 dst) => dst = (I8)src; | |||
public void Convert(ref BL src, ref R4 dst) => dst = (R4)src; | |||
public void Convert(ref BL src, ref R8 dst) => dst = (R8)src; | |||
public void Convert(ref BL src, ref R4 dst) => dst = System.Convert.ToSingle(src); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System [](start = 61, length = 6)
you have using System; in beginning of file, is this System necessary? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -596,7 +596,7 @@ public override void AttachMetadata(MetadataDispatcher.Builder bldr, ColumnType | |||
Host.Check(typeSrc.RawType == typeof(TFloat)); | |||
bldr.AddPrimitive("CdfMean", typeSrc, Mean); | |||
bldr.AddPrimitive("CdfStdDev", typeSrc, Stddev); | |||
bldr.AddPrimitive("CdfUseLog", BoolType.Instance, (DvBool)UseLog); | |||
bldr.AddPrimitive("CdfUseLog", BoolType.Instance, (bool)UseLog); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(bool) [](start = 70, length = 6)
not necessary, UseLog already bool #Resolved
@@ -625,7 +625,7 @@ public override void AttachMetadata(MetadataDispatcher.Builder bldr, ColumnType | |||
Host.Check(typeSrc.ItemType.RawType == typeof(TFloat)); | |||
bldr.AddGetter<VBuffer<TFloat>>("CdfMean", typeSrc, MeanMetadataGetter); | |||
bldr.AddGetter<VBuffer<TFloat>>("CdfStdDev", typeSrc, StddevMetadataGetter); | |||
bldr.AddPrimitive("CdfUseLog", BoolType.Instance, (DvBool)UseLog); | |||
bldr.AddPrimitive("CdfUseLog", BoolType.Instance, (bool)UseLog); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool [](start = 71, length = 4)
not necessary, UseLog already bool #Resolved
@@ -368,8 +368,8 @@ private void FillValues(int srcLength, ref VBuffer<DvBool> dst, List<int> indice | |||
|
|||
int ii = 0; | |||
// Assigns values correctly depending on the sense. | |||
DvBool hit = sense ? DvBool.True : DvBool.False; | |||
DvBool miss = sense ? DvBool.False : DvBool.True; | |||
bool hit = sense; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool hit = sense; [](start = 16, length = 17)
is it necessary? can you just use sense instead of hit? (I'm totally fine with miss) #Resolved
@@ -10,60 +10,6 @@ namespace Microsoft.ML.Runtime.RunTests | |||
{ | |||
public sealed class DvTypeTests | |||
{ | |||
[Fact] | |||
public void TestComparableDvInt4() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TestComparableDvInt4 [](start = 20, length = 20)
why you removing whole test? Is DvInt4 gone already or in this PR? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is another PR that removes DvInt* #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -309,7 +309,6 @@ public class ConversionNullalbeClass | |||
public ulong? fuLong; | |||
public float? fFloat; | |||
public double? fDouble; | |||
public bool? fBool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public bool? fBool; [](start = 12, length = 19)
This kinda make me sad.
I understand what we want to have pure framework, and as workaround we force people to cast everything to float which support NaNs, it just in my life I worked with Something2SQL frameworks, and quite often you have nullable boolean columns, and if they fetch through DTO object, it will make that object uncastable /unwrappable for our collection to dataview.
Which will lead to bunch of painful casting/objects recreations.
But again, what do I know about life. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, read Tom's comment on the issue page you might become happy! :)
In reply to: 211109825 [](ancestors = 211109825)
Can you link issue which trigger this PR? #Resolved |
Are you removing DvBool.cs in a followup PR? #Resolved |
} | ||
|
||
[Fact] | ||
public void NullableBooleanLabelPipeline() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we decided we wanted to support bool?
? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a compelling reason?
CC: @TomFinley #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We appear to have tests that use it - https://github.com/dotnet/machinelearning/pull/692/files#diff-a18fb7e769859c74ab2d303040626b57. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, Tom, didn't think there is a compelling reason to support bool? But if you can think of something then let me know. There were two places where bool? was being used in the codebase and they were both in prediction label from score, i.e if score was null then assign predicted label as NA but we defaulted to false for missing and you can see the change in test results. Tom is ok with this.
In reply to: 211434928 [](ancestors = 211434928)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, this is from nullable stuff that comes in from sql tables, we don;t need to support this, please see Tom;s comment on the issue comment section.
In reply to: 211678395 [](ancestors = 211678395)
Yes. In reply to: 414418364 [](ancestors = 414418364) |
@@ -63,8 +63,7 @@ public CodecFactory(IHostEnvironment env, MemoryStreamPool memPool = null) | |||
|
|||
// Register the old boolean reading codec. | |||
var oldBool = new OldBoolCodec(this); | |||
RegisterOtherCodec(oldBool.LoadName, oldBool.GetCodec); | |||
|
|||
RegisterOtherCodec("DvBool", oldBool.GetCodec); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we removed DvBool
. ? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its for backward compatibility, incase someone saves a dataset in IDV format with the old DvTypes and loads in ML.NET without DvTypes.
In reply to: 213403080 [](ancestors = 213403080)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We aren't doing that for the other Dv types.... Why are we doing it for DvBool?
In reply to: 213408068 [](ancestors = 213408068,213403080)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm doing for DvDate/Time as well. For DvInt we don't need to change because the key for codec has not changed. The key is used to retrieve the codec to parse when the loader reads the signature string.
DvBool is the only codec where we have also modified the codec as well to use one bit to write a boolean value as opposed to two bits. We need the old codec to read values from IDV that was written using DvBool.
In reply to: 213420305 [](ancestors = 213420305,213408068,213403080)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…to dvbool # Conflicts: # test/Microsoft.ML.TestFramework/DataPipe/TestDataPipeBase.cs
…to dvbool # Conflicts: # test/BaselineOutput/SingleDebug/SavePipe/TestParquetPrimitiveDataTypes-Data.txt # test/BaselineOutput/SingleDebug/SavePipe/TestParquetPrimitiveDataTypes-Schema.txt # test/BaselineOutput/SingleRelease/SavePipe/TestParquetPrimitiveDataTypes-Data.txt # test/BaselineOutput/SingleRelease/SavePipe/TestParquetPrimitiveDataTypes-Schema.txt # test/data/Parquet/alltypes.parquet
…to dvbool # Conflicts: # src/Microsoft.ML.Data/Transforms/NormalizeTransform.cs
This change was committed via #863 |
fixes #673