Skip to content

Commit 752871b

Browse files
committed
Add syntatic suggar
1 parent 3cc9093 commit 752871b

File tree

2 files changed

+41
-13
lines changed

2 files changed

+41
-13
lines changed

src/AI-DataImputers-Tests/AISimpleImputerTest.class.st

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,39 +90,35 @@ AISimpleImputerTest >> testTransform1DColl [
9090
{ #category : #tests }
9191
AISimpleImputerTest >> testTransformAverage [
9292

93-
imputer
94-
useAverage;
95-
fit: collection.
93+
imputer := AISimpleImputer average.
94+
imputer fit: collection.
9695

9796
self assert: (imputer transform: collection) equals: #( #( 7 2 5 6 ) #( 7 2 5 9 ) #( 10 2 5 6 ) )
9897
]
9998

10099
{ #category : #tests }
101100
AISimpleImputerTest >> testTransformConstant [
102101

103-
imputer
104-
useConstant: 10;
105-
fit: collection.
102+
imputer := AISimpleImputer constant: 10.
103+
imputer fit: collection.
106104

107-
self assert: (imputer transform: collection) equals: #( #( 7 2 5 6 ) #( 7 10 5 9 ) #( 10 2 10 6 ) ).
105+
self assert: (imputer transform: collection) equals: #( #( 7 2 5 6 ) #( 7 10 5 9 ) #( 10 2 10 6 ) )
108106
]
109107

110108
{ #category : #tests }
111109
AISimpleImputerTest >> testTransformMedian [
112110

113-
imputer
114-
useAverage;
115-
fit: collection.
111+
imputer := AISimpleImputer median.
112+
imputer fit: collection.
116113

117114
self assert: (imputer transform: collection) equals: #( #( 7 2 5 6 ) #( 7 2 5 9 ) #( 10 2 5 6 ) )
118115
]
119116

120117
{ #category : #tests }
121118
AISimpleImputerTest >> testTransformMostFrequent [
122119

123-
imputer
124-
useMostFrequent;
125-
fit: collection.
120+
imputer := AISimpleImputer mostFrequent.
121+
imputer fit: collection.
126122

127123
self assert: (imputer transform: collection) equals: #( #( 7 2 5 6 ) #( 7 2 5 9 ) #( 10 2 5 6 ) )
128124
]

src/AI-DataImputers/AISimpleImputer.class.st

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,38 @@ Class {
7272
#category : #'AI-DataImputers'
7373
}
7474

75+
{ #category : #'instance creation' }
76+
AISimpleImputer class >> average [
77+
78+
^ self new
79+
useAverage;
80+
yourself
81+
]
82+
83+
{ #category : #'instance creation' }
84+
AISimpleImputer class >> constant: aNumber [
85+
86+
^ self new
87+
useConstant: aNumber;
88+
yourself
89+
]
90+
91+
{ #category : #'instance creation' }
92+
AISimpleImputer class >> median [
93+
94+
^ self new
95+
useMedian;
96+
yourself
97+
]
98+
99+
{ #category : #'instance creation' }
100+
AISimpleImputer class >> mostFrequent [
101+
102+
^ self new
103+
useMostFrequent;
104+
yourself
105+
]
106+
75107
{ #category : #private }
76108
AISimpleImputer >> ensureIs2D: aCollection [
77109

0 commit comments

Comments
 (0)