def classify(self, data):
if 'version' not in self._model.config:
logging.error('Trying to use MetadataClassifier without learning first')
return utility.get_zero_class_dict()
if self._model.config['version'] != sklearn.__version__:
logging.error('Using MetadataClassifier with different scikit learn version (trained on: {}, used: {}) - relearn classifier first'.format(self._model.config['version'], sklearn.__version__))
return utility.get_zero_class_dict()
if self._tree is None:
self._tree = pickle.loads(base64.b64decode(self._model.config['tree']))
probability = self._tree.predict_proba([self._get_input(data)])
result = utility.get_zero_class_dict()
for i in range(len(self._tree.classes_)):
result[self._tree.classes_[i]] = probability[0][i]
return result
##
# \brief Trains a <em>Decision Tree</em> based on the provided repositories.
#
# \param learn List containing Tupel (GITHUB, CLASS), where GITHUB is the repository as a github.Github class and
# CLASS is the class label of the repository as a string.
评论列表
文章目录