| 66 | |
| 67 | |
| 68 | class CustomKerasModelWrapper(ModelWrapper): |
| 69 | def __init__(self, model): |
| 70 | self.model = model |
| 71 | |
| 72 | def __call__(self, text_input_list): |
| 73 | x_transform = [] |
| 74 | for i, review in enumerate(text_input_list): |
| 75 | tokens = [x.strip(",") for x in review.split()] |
| 76 | BoW_array = np.zeros((NUM_WORDS,)) |
| 77 | for word in tokens: |
| 78 | if word in vocabulary: |
| 79 | if vocabulary[word] < len(BoW_array): |
| 80 | BoW_array[vocabulary[word]] += 1 |
| 81 | x_transform.append(BoW_array) |
| 82 | x_transform = np.array(x_transform) |
| 83 | prediction = self.model.predict(x_transform) |
| 84 | return prediction |
| 85 | |
| 86 | |
| 87 | model = Sequential() |
no outgoing calls
no test coverage detected