Skip to content

Commit b94d3c6

Browse files
committed
codes and documentation for stacking cleaned up
1 parent 66f1ac3 commit b94d3c6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

docs/tutorial_stacking.rst

+5
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ offered in this package. To load them, initialize it in the same way:
7777
>>> stacker2 = shorttext.stack.LogisticStackedGeneralization(intermediate_classifiers={'clstm': clstm_classifier, 'lda128': lda128_svm_classifier})
7878
>>> stacker2.load_compact_model('/path/to/logitmodel.bin')
7979

80+
81+
.. automodule:: shorttext.stack.stacking
82+
:members:
83+
84+
8085
Reference
8186
---------
8287

shorttext/stack/stacking.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pickle
2+
from abc import ABC, abstractmethod
23

34
import numpy as np
45
from keras.layers import Dense, Reshape
@@ -11,7 +12,7 @@
1112

1213

1314
# abstract class
14-
class StackedGeneralization:
15+
class StackedGeneralization(ABC):
1516
"""
1617
This is an abstract class for any stacked generalization method. It is an intermediate model
1718
that takes the results of other classifiers as the input features, and perform another classification.
@@ -136,6 +137,7 @@ def convert_traindata_matrix(self, classdict, tobucket=True):
136137
X = self.translate_shorttext_intfeature_matrix(shorttext)
137138
yield X, y
138139

140+
@abstractmethod
139141
def train(self, classdict, *args, **kwargs):
140142
""" Train the stacked generalization.
141143
@@ -152,6 +154,7 @@ def train(self, classdict, *args, **kwargs):
152154
"""
153155
raise e.NotImplementedException()
154156

157+
@abstractmethod
155158
def score(self, shorttext, *args, **kwargs):
156159
""" Calculate the scores for each class labels.
157160

0 commit comments

Comments
 (0)