mirror of
https://github.com/Steffo99/unimore-bda-6.git
synced 2024-11-25 17:24:20 +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
|
run_counter += 1
|
||||||
slog.debug("Run #%d", run_counter)
|
slog.debug("Run #%d", run_counter)
|
||||||
|
|
||||||
|
if run_counter >= 100:
|
||||||
|
slog.fatal("Exceeded 100 runs, giving up and exiting...")
|
||||||
|
exit(2)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
slog.debug("Instantiating %s with %s...", SentimentAnalyzer.__name__, Tokenizer.__name__)
|
slog.debug("Instantiating %s with %s...", SentimentAnalyzer.__name__, Tokenizer.__name__)
|
||||||
sa = SentimentAnalyzer(tokenizer=Tokenizer())
|
sa = SentimentAnalyzer(tokenizer=Tokenizer())
|
||||||
|
|
|
@ -50,8 +50,11 @@ class BaseSentimentAnalyzer(metaclass=abc.ABCMeta):
|
||||||
for review in evaluation_dataset_func():
|
for review in evaluation_dataset_func():
|
||||||
resulting_category = self.use(review.text)
|
resulting_category = self.use(review.text)
|
||||||
evaluated += 1
|
evaluated += 1
|
||||||
correct += 1 if round(resulting_category) == round(review.category) else 0
|
try:
|
||||||
score += 1 - (abs(resulting_category - review.category) / 4)
|
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)
|
return EvaluationResults(correct=correct, evaluated=evaluated, score=score)
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ class TensorflowPolarSentimentAnalyzer(TensorflowSentimentAnalyzer):
|
||||||
|
|
||||||
log.debug("Compiling model: %s", model)
|
log.debug("Compiling model: %s", model)
|
||||||
model.compile(
|
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(),
|
loss=tensorflow.keras.losses.MeanSquaredError(),
|
||||||
metrics=[
|
metrics=[
|
||||||
tensorflow.keras.metrics.MeanAbsoluteError(),
|
tensorflow.keras.metrics.MeanAbsoluteError(),
|
||||||
|
|
Loading…
Reference in a new issue