Skip to content

Commit

Permalink
Move test method to DataFrame test specific package.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hernán Morales Durand committed Dec 14, 2023
1 parent de2790e commit 318f5a3
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Class {
#name : #AIHashPartitionerDataFrameTest,
#superclass : #TestCase,
#category : #'AI-DataPartitioners-DataFrameTests'
#name : 'AIHashPartitionerDataFrameTest',
#superclass : 'TestCase',
#category : 'AI-DataPartitioners-DataFrameTests',
#package : 'AI-DataPartitioners-DataFrameTests'
}

{ #category : #tests }
{ #category : 'tests' }
AIHashPartitionerDataFrameTest >> testPartitionDataFrameWithCustomRowNames [

| dataFrame proportions subsets |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
Class {
#name : #AIRandomPartitionerDataFrameTest,
#superclass : #TestCase,
#category : #'AI-DataPartitioners-DataFrameTests'
#name : 'AIRandomPartitionerDataFrameTest',
#superclass : 'TestCase',
#instVars : [
'df'
],
#category : 'AI-DataPartitioners-DataFrameTests',
#package : 'AI-DataPartitioners-DataFrameTests'
}

{ #category : #tests }
{ #category : 'running' }
AIRandomPartitionerDataFrameTest >> setUp [

super setUp.
df := DataFrame withRows: #( #( 'Barcelona' 1.609 true ) #( 'Dubai' 2.789 true ) #( 'London' 8.788 false ) ).

df rowNames: #( 'A' 'B' 'C' ).
df columnNames: #( 'City' 'Population' 'BeenThere' )
]

{ #category : 'tests' }
AIRandomPartitionerDataFrameTest >> testPartitionDataFrameWithCustomRowNames [
| dataFrame sizes partitioner subsets |

Expand All @@ -30,7 +44,7 @@ AIRandomPartitionerDataFrameTest >> testPartitionDataFrameWithCustomRowNames [
self assert: (dataFrame row: rowName) equals: (eachSubset row: rowName) ] ].
]

{ #category : #tests }
{ #category : 'tests' }
AIRandomPartitionerDataFrameTest >> testPartitionDataSeriesWithCustomKeys [
| series sizes partitioner subsets |

Expand All @@ -54,7 +68,7 @@ AIRandomPartitionerDataFrameTest >> testPartitionDataSeriesWithCustomKeys [
self assert: key equals: (series keyAtValue: value) ] ].
]

{ #category : #tests }
{ #category : 'tests' }
AIRandomPartitionerDataFrameTest >> testPartitionDataSeriesWithDefaultKeys [
| series sizes partitioner subsets |

Expand All @@ -76,3 +90,38 @@ AIRandomPartitionerDataFrameTest >> testPartitionDataSeriesWithDefaultKeys [
eachSubset keysAndValuesDo: [ :key :value |
self assert: key equals: (series keyAtValue: value) ] ].
]

{ #category : 'tests' }
AIRandomPartitionerDataFrameTest >> testSplitTrainTestFromUsingTargetColumnWithProportionsShuffle [

| expectedPartition partitionedDataSet |

expectedPartition := AIPartitionedDataSet new
xTrain: (DataFrame
withRows: #( #( 'Barcelona' 1.609 ) #( 'London' 8.788 ))
rowNames: #('A' 'C')
columnNames: #( 'City' 'Population' ));
xTest: (DataFrame
withRows: #( #( 'Dubai' 2.789 ))
rowNames: #('B')
columnNames: #( 'City' 'Population' ));
yTrain: (DataFrame
withRows: #( #( true ) #( false ))
rowNames: #('A' 'C')
columnNames: #( 'BeenThere' ));
yTest: (DataFrame
withRows: #( #( true ))
rowNames: #('B')
columnNames: #( 'BeenThere' ));
yourself.

partitionedDataSet := (AIRandomPartitioner new
splitTrainTestFrom: df
usingTargetColumn: #('BeenThere')
withProportions: #(0.7 0.3)
seed: 1).

self
assert: partitionedDataSet
equals: expectedPartition
]
2 changes: 1 addition & 1 deletion src/AI-DataPartitioners-DataFrameTests/package.st
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Package { #name : #'AI-DataPartitioners-DataFrameTests' }
Package { #name : 'AI-DataPartitioners-DataFrameTests' }
45 changes: 0 additions & 45 deletions src/AI-DataPartitioners-Tests/AIRandomPartitionerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ Class {
#package : 'AI-DataPartitioners-Tests'
}

{ #category : 'running' }
AIRandomPartitionerTest >> setUp [

super setUp.
df := DataFrame withRows: #( #( 'Barcelona' 1.609 true ) #( 'Dubai' 2.789 true ) #( 'London' 8.788 false ) ).

df rowNames: #( 'A' 'B' 'C' ).
df columnNames: #( 'City' 'Population' 'BeenThere' )
]

{ #category : 'tests' }
AIRandomPartitionerTest >> testSplitDataWithProportionsCase1 [

Expand Down Expand Up @@ -80,38 +70,3 @@ AIRandomPartitionerTest >> testSplitDataWithSizesCase2 [
self assert: subsetsSizes sum equals: data size.
self assert: subsetsSizes equals: sizes
]

{ #category : 'tests' }
AIRandomPartitionerTest >> testSplitTrainTestFromUsingTargetColumnWithProportionsShuffle [

| expectedPartition partitionedDataSet |

expectedPartition := AIPartitionedDataSet new
xTrain: (DataFrame
withRows: #( #( 'Barcelona' 1.609 ) #( 'London' 8.788 ))
rowNames: #('A' 'C')
columnNames: #( 'City' 'Population' ));
xTest: (DataFrame
withRows: #( #( 'Dubai' 2.789 ))
rowNames: #('B')
columnNames: #( 'City' 'Population' ));
yTrain: (DataFrame
withRows: #( #( true ) #( false ))
rowNames: #('A' 'C')
columnNames: #( 'BeenThere' ));
yTest: (DataFrame
withRows: #( #( true ))
rowNames: #('B')
columnNames: #( 'BeenThere' ));
yourself.

partitionedDataSet := (AIRandomPartitioner new
splitTrainTestFrom: df
usingTargetColumn: #('BeenThere')
withProportions: #(0.7 0.3)
seed: 1).

self
assert: partitionedDataSet
equals: expectedPartition
]

0 comments on commit 318f5a3

Please sign in to comment.