mirror of
https://github.com/Steffo99/unimore-bda-6.git
synced 2024-11-21 23:44:19 +00:00
idk something more & more
This commit is contained in:
parent
03c6123d85
commit
07be21e809
3 changed files with 10 additions and 3 deletions
|
@ -65,6 +65,10 @@ def main():
|
|||
run_counter += 1
|
||||
slog.debug("Run #%d", run_counter)
|
||||
|
||||
if run_counter >= 100:
|
||||
slog.fatal("Exceeded 100 runs, giving up and exiting...")
|
||||
exit(2)
|
||||
|
||||
try:
|
||||
slog.debug("Instantiating %s with %s...", SentimentAnalyzer.__name__, Tokenizer.__name__)
|
||||
sa = SentimentAnalyzer(tokenizer=Tokenizer())
|
||||
|
|
|
@ -50,8 +50,11 @@ class BaseSentimentAnalyzer(metaclass=abc.ABCMeta):
|
|||
for review in evaluation_dataset_func():
|
||||
resulting_category = self.use(review.text)
|
||||
evaluated += 1
|
||||
try:
|
||||
correct += 1 if round(resulting_category) == round(review.category) else 0
|
||||
score += 1 - (abs(resulting_category - review.category) / 4)
|
||||
except ValueError:
|
||||
log.warning("Model execution on %s resulted in a NaN value: %s", review, resulting_category)
|
||||
|
||||
return EvaluationResults(correct=correct, evaluated=evaluated, score=score)
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ class TensorflowPolarSentimentAnalyzer(TensorflowSentimentAnalyzer):
|
|||
|
||||
log.debug("Compiling model: %s", model)
|
||||
model.compile(
|
||||
optimizer=tensorflow.keras.optimizers.Adam(global_clipnorm=1.0),
|
||||
optimizer=tensorflow.keras.optimizers.Adadelta(global_clipnorm=1.0),
|
||||
loss=tensorflow.keras.losses.MeanSquaredError(),
|
||||
metrics=[
|
||||
tensorflow.keras.metrics.MeanAbsoluteError(),
|
||||
|
|
Loading…
Reference in a new issue