Skip to content

Commit

Permalink
removed PartialFit method from CountVectoriser
Browse files Browse the repository at this point in the history
  • Loading branch information
james-bowman committed Aug 28, 2018
1 parent b97145e commit 5c65a63
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 40 deletions.
12 changes: 0 additions & 12 deletions vectorisers.go
Expand Up @@ -166,18 +166,6 @@ func (v *CountVectoriser) Fit(train ...string) Vectoriser {
return v
}

// PartialFit processes the supplied training data (a variable number of strings
// representing documents). Each word appearing inside the training data will be
// added to the Vocabulary. Unlike Fit(), PartialFit() is intended to be called
// multiple times to incrementally train the model and so is intended for online
// or mini-batch training as opposed to batch training as with the Fit() method.
func (v *CountVectoriser) PartialFit(train ...string) OnlineVectoriser {
i := len(v.Vocabulary)
v.fitVocab(i, train...)

return v
}

// fitVocab learns the vocabulary contained within the supplied training documents
func (v *CountVectoriser) fitVocab(start int, train ...string) {
i := start
Expand Down
28 changes: 0 additions & 28 deletions vectorisers_test.go
Expand Up @@ -50,34 +50,6 @@ func TestCountVectoriserFit(t *testing.T) {
}
}
}

func TestCountVectoriserPartialFit(t *testing.T) {
var tests = []struct {
train []string
stop []string
vocabSize int
}{
{trainSet, []string{}, 26},
{trainSet[0:1], []string{}, 8},
{trainSet, stopWords, 18},
}

for testRun, test := range tests {
t.Logf("**** Test Run %d.\n", testRun+1)
vectoriser := NewCountVectoriser(test.stop...)

for _, v := range test.train {
vectoriser.PartialFit(v)
}

if len(vectoriser.Vocabulary) != test.vocabSize {
t.Logf("Expected training dataset %v of size %d but found vocabulary %v of size %d",
test.train, test.vocabSize, vectoriser.Vocabulary, len(vectoriser.Vocabulary))
t.Fail()
}
}
}

func TestCountVectoriserTransform(t *testing.T) {
var tests = []struct {
train []string
Expand Down

0 comments on commit 5c65a63

Please sign in to comment.