@@ -110,5 +110,54 @@ public void NoTransformPipeline()
110110 pipeline . Add ( new FastForestBinaryClassifier ( ) ) ;
111111 var model = pipeline . Train < Data , Prediction > ( ) ;
112112 }
113+
114+ public class BooleanLabelData
115+ {
116+ [ ColumnName ( "Features" ) ]
117+ [ VectorType ( 2 ) ]
118+ public float [ ] Features ;
119+
120+ [ ColumnName ( "Label" ) ]
121+ public bool Label ;
122+ }
123+
124+ [ Fact ]
125+ public void BooleanLabelPipeline ( )
126+ {
127+ var data = new BooleanLabelData [ 1 ] ;
128+ data [ 0 ] = new BooleanLabelData ( ) ;
129+ data [ 0 ] . Features = new float [ ] { 0.0f , 1.0f } ;
130+ data [ 0 ] . Label = false ;
131+ var pipeline = new LearningPipeline ( ) ;
132+ pipeline . Add ( CollectionDataSource . Create ( data ) ) ;
133+ pipeline . Add ( new FastForestBinaryClassifier ( ) ) ;
134+ var model = pipeline . Train < Data , Prediction > ( ) ;
135+ }
136+
137+ public class NullableBooleanLabelData
138+ {
139+ [ ColumnName ( "Features" ) ]
140+ [ VectorType ( 2 ) ]
141+ public float [ ] Features ;
142+
143+ [ ColumnName ( "Label" ) ]
144+ public bool ? Label ;
145+ }
146+
147+ [ Fact ]
148+ public void NullableBooleanLabelPipeline ( )
149+ {
150+ var data = new NullableBooleanLabelData [ 2 ] ;
151+ data [ 0 ] = new NullableBooleanLabelData ( ) ;
152+ data [ 0 ] . Features = new float [ ] { 0.0f , 1.0f } ;
153+ data [ 0 ] . Label = null ;
154+ data [ 1 ] = new NullableBooleanLabelData ( ) ;
155+ data [ 1 ] . Features = new float [ ] { 1.0f , 0.0f } ;
156+ data [ 1 ] . Label = false ;
157+ var pipeline = new LearningPipeline ( ) ;
158+ pipeline . Add ( CollectionDataSource . Create ( data ) ) ;
159+ pipeline . Add ( new FastForestBinaryClassifier ( ) ) ;
160+ var model = pipeline . Train < Data , Prediction > ( ) ;
161+ }
113162 }
114163}
0 commit comments