I made a model in keras to predict spam messages, the last activation is sigmoid, but the output is not exactly between 0 and 1
# define the model
model = Sequential()
model.add(Embedding(vocab_size, 30, input_length=max_length))
model.add(Flatten())
model.add(Dense(500, activation='relu'))
model.add(Dense(200, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(100, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
# compile the model
model.compile(optimizer='rmsprop', loss='binary_crossentropy', metrics=['accuracy'])
The predict example:
sms = ["Hello whats your name"]
sms_proc = tokenizer.texts_to_sequences(sms)
sms_proc = pad_sequences(sms_proc, maxlen=10, padding='post')
pred = (model.predict(sms_proc)).item()
print(pred)
Output:
1.9402589257477842e-10
Test:
print(pred > 0)
print(pred < 1)
Output:
True
True
I know this number "1.9402589257477842e-10" is between 0 and 1, but is it possible to display it without the notation? For example: 0.0000001