Exemple #1
0
 async def accuracy(self, sources: Sources) -> Accuracy:
     """
     Evaluates the accuracy of our model after training using the input repos
     as test data.
     """
     if not os.path.isdir(self.model_dir_path):
         raise ModelNotTrained("Train model before assessing for accuracy.")
     input_fn = await self.accuracy_input_fn(sources)
     accuracy_score = self.model.evaluate(input_fn=input_fn)
     return Accuracy(accuracy_score["accuracy"])
Exemple #2
0
 async def accuracy(self, sources: Sources) -> Accuracy:
     """
     Evaluates the accuracy of our model after training using the input repos
     as test data.
     """
     if not os.path.isdir(self.model_dir_path):
         raise NotADirectoryError("Model not trained")
     input_fn = await self.evaluate_input_fn(
         sources, batch_size=20, shuffle=False, epochs=1
     )
     metrics = self.model.evaluate(input_fn=input_fn)
     return Accuracy(1 - metrics["loss"])  # 1 - mse
Exemple #3
0
 async def accuracy(self, sources: Sources, features: Features,
         classifications: List[Any]) -> Accuracy:
     '''
     Evaluates the accuracy of our model after training using the input repos
     as test data.
     '''
     if not os.path.isdir(self.model_dir_path(features)):
         raise NotADirectoryError('Model not trained')
     input_fn = await self.accuracy_input_fn(sources, features,
             classifications,
             batch_size=20, shuffle=False, num_epochs=1)
     accuracy_score = (await self.model(features, classifications))\
             .evaluate(input_fn=input_fn)
     return Accuracy(accuracy_score['accuracy'])
Exemple #4
0
 async def accuracy(self, sources: Sources) -> Accuracy:
     if self.regression_line is None:
         raise ModelNotTrained("Train model before assessing for accuracy.")
     accuracy_value = self.regression_line[2]
     return Accuracy(accuracy_value)
Exemple #5
0
 async def accuracy(self, sources: Sources) -> Accuracy:
     if self.regression_line is None:
         raise ValueError("Model Not Trained")
     accuracy_value = self.regression_line[2]
     return Accuracy(accuracy_value)
Exemple #6
0
 async def accuracy(self, sources: Sources) -> Accuracy:
     accuracy: int = 0
     async for repo in sources.repos():
         accuracy += int(repo.key)
     return Accuracy(accuracy)
Exemple #7
0
 def test_str(self):
     self.assertEqual(str(Accuracy(0.04242)), "4.24")