2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
// See the LICENSE file in the project root for more information.
4
4
5
- using Microsoft . ML ;
6
5
using Microsoft . ML . Data ;
7
6
using Microsoft . ML . Runtime . Api ;
8
7
using Microsoft . ML . Runtime . Data ;
@@ -34,9 +33,9 @@ public void CanAddAndRemoveFromPipeline()
34
33
{
35
34
var pipeline = new LearningPipeline ( )
36
35
{
37
- new Transforms . CategoricalOneHotVectorizer ( "String1" , "String2" ) ,
38
- new Transforms . ColumnConcatenator ( outputColumn : "Features" , "String1" , "String2" , "Number1" , "Number2" ) ,
39
- new Trainers . StochasticDualCoordinateAscentRegressor ( )
36
+ new CategoricalOneHotVectorizer ( "String1" , "String2" ) ,
37
+ new ColumnConcatenator ( outputColumn : "Features" , "String1" , "String2" , "Number1" , "Number2" ) ,
38
+ new StochasticDualCoordinateAscentRegressor ( )
40
39
} ;
41
40
Assert . NotNull ( pipeline ) ;
42
41
Assert . Equal ( 3 , pipeline . Count ) ;
@@ -66,7 +65,7 @@ private class TransformedData
66
65
public void TransformOnlyPipeline ( )
67
66
{
68
67
const string _dataPath = @"..\..\Data\breast-cancer.txt" ;
69
- var pipeline = new LearningPipeline ( ) ;
68
+ var pipeline = new LearningPipeline ( seed : 1 , conc : 1 ) ;
70
69
pipeline . Add ( new ML . Data . TextLoader ( _dataPath ) . CreateFrom < InputData > ( useHeader : false ) ) ;
71
70
pipeline . Add ( new CategoricalHashOneHotVectorizer ( "F1" ) { HashBits = 10 , Seed = 314489979 , OutputKind = CategoricalTransformOutputKind . Bag } ) ;
72
71
var model = pipeline . Train < InputData , TransformedData > ( ) ;
@@ -103,9 +102,11 @@ public class Prediction
103
102
public void NoTransformPipeline ( )
104
103
{
105
104
var data = new Data [ 1 ] ;
106
- data [ 0 ] = new Data ( ) ;
107
- data [ 0 ] . Features = new float [ ] { 0.0f , 1.0f } ;
108
- data [ 0 ] . Label = 0f ;
105
+ data [ 0 ] = new Data
106
+ {
107
+ Features = new float [ ] { 0.0f , 1.0f } ,
108
+ Label = 0f
109
+ } ;
109
110
var pipeline = new LearningPipeline ( ) ;
110
111
pipeline . Add ( CollectionDataSource . Create ( data ) ) ;
111
112
pipeline . Add ( new FastForestBinaryClassifier ( ) ) ;
@@ -126,9 +127,11 @@ public class BooleanLabelData
126
127
public void BooleanLabelPipeline ( )
127
128
{
128
129
var data = new BooleanLabelData [ 1 ] ;
129
- data [ 0 ] = new BooleanLabelData ( ) ;
130
- data [ 0 ] . Features = new float [ ] { 0.0f , 1.0f } ;
131
- data [ 0 ] . Label = false ;
130
+ data [ 0 ] = new BooleanLabelData
131
+ {
132
+ Features = new float [ ] { 0.0f , 1.0f } ,
133
+ Label = false
134
+ } ;
132
135
var pipeline = new LearningPipeline ( ) ;
133
136
pipeline . Add ( CollectionDataSource . Create ( data ) ) ;
134
137
pipeline . Add ( new FastForestBinaryClassifier ( ) ) ;
@@ -149,12 +152,16 @@ public class NullableBooleanLabelData
149
152
public void NullableBooleanLabelPipeline ( )
150
153
{
151
154
var data = new NullableBooleanLabelData [ 2 ] ;
152
- data [ 0 ] = new NullableBooleanLabelData ( ) ;
153
- data [ 0 ] . Features = new float [ ] { 0.0f , 1.0f } ;
154
- data [ 0 ] . Label = null ;
155
- data [ 1 ] = new NullableBooleanLabelData ( ) ;
156
- data [ 1 ] . Features = new float [ ] { 1.0f , 0.0f } ;
157
- data [ 1 ] . Label = false ;
155
+ data [ 0 ] = new NullableBooleanLabelData
156
+ {
157
+ Features = new float [ ] { 0.0f , 1.0f } ,
158
+ Label = null
159
+ } ;
160
+ data [ 1 ] = new NullableBooleanLabelData
161
+ {
162
+ Features = new float [ ] { 1.0f , 0.0f } ,
163
+ Label = false
164
+ } ;
158
165
var pipeline = new LearningPipeline ( ) ;
159
166
pipeline . Add ( CollectionDataSource . Create ( data ) ) ;
160
167
pipeline . Add ( new FastForestBinaryClassifier ( ) ) ;
0 commit comments