def metrics(): _value = main.get_metrics( application.config['CB_DATABASE'], application.config['CB_USERNAME'], application.config['CB_PASSWORD']) if application.config['CB_STREAMING']: def generate(): for row in _value: yield(row + "\n") return Response(stream_with_context(generate()), mimetype='text/plain') else: metrics_str = "\n" metrics_str = metrics_str.join(_value) return Response(metrics_str, mimetype='text/plain')
def test_get_metrics(): dataset = sklearn.datasets.load_breast_cancer() var2 = sklearn.cluster.KMeans(4) var2.fit(dataset['data']) true = dataset['target'] pred = var2.predict(dataset['data']) print("H(reel)", sklearn.metrics.cluster.entropy(true)) print("H(pred)", sklearn.metrics.cluster.entropy(pred)) MI = sklearn.metrics.cluster.mutual_info_score(true, pred) print("MI", MI) cont = utility.compute_contingency(true, pred) rep = main.get_metrics(true, pred) for a in rep: print(a, "\t", rep[a]) print(cont)
def metrics(): num_samples = 60 if request.args.get('num_samples'): num_samples = int(request.args.get('num_samples')) result_set = 60 if application.config['CB_RESULTSET']: result_set = application.config['CB_RESULTSET'] _value = main.get_metrics( application.config['CB_DATABASE'], application.config['CB_USERNAME'], application.config['CB_PASSWORD'], num_samples, result_set) if application.config['CB_STREAMING']: def generate(): for row in _value: yield(row + '\n') return Response(stream_with_context(generate()), mimetype='text/plain') else: metrics_str = '\n' metrics_str = metrics_str.join(_value) return Response(metrics_str, mimetype='text/plain')
def test_get_metrics(self): print(main.get_metrics(good_event, context))