SNAP Library 2.2, User Reference
2014-03-11 19:15:55
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include "stdafx.h"
Go to the source code of this file.
Classes | |
class | TGraphAttributes |
class | TCluster |
Typedefs | |
typedef TPt< TGraphAttributes > | PGraphAttributes |
typedef TPt< TCluster > | PCluster |
Enumerations | |
enum | lossType { zeroOne = 0, balancedError = 1, fScore = 2 } |
Functions | |
TFlt | Loss (TIntSet &l, TIntSet lHat, int N, int Which) |
Compute the loss between a GroundTruth cluster l and a predicted cluster lHat. | |
TFlt | Inner (TIntIntH &Feature, TFlt *Parameter) |
Inner product for sparse features. |
typedef TPt<TGraphAttributes> PGraphAttributes |
enum lossType |
Definition at line 95 of file circles.h.
{ zeroOne = 0, balancedError = 1, fScore = 2 };
Compute the loss between a GroundTruth cluster l and a predicted cluster lHat.
Definition at line 103 of file circles.h.
{ if (l.Len() == 0) { if (lHat.Len() == 0) { return 0; } return 1.0; } if (lHat.Len() == 0) { if (l.Len() == 0) { return 0; } return 1.0; } TInt TruePositives = 0; TInt FalsePositives = 0; TInt FalseNegatives = 0; TFlt LabelLoss = 0; for (THashSetKeyI<TInt> it = l.BegI(); it != l.EndI(); it ++) { int c = it.GetKey(); if (not lHat.IsKey(c)) { // false negative FalseNegatives ++; if (Which == zeroOne) { LabelLoss += 1.0/N; } else if (Which == balancedError) { LabelLoss += 0.5/l.Len(); } } } for (THashSetKeyI<TInt> it = lHat.BegI(); it != lHat.EndI(); it ++) { int c = it.GetKey(); if (not l.IsKey(c)) { // false positive FalsePositives ++; if (Which == zeroOne) { LabelLoss += 1.0/N; } else if (Which == balancedError) { LabelLoss += 0.5/(N - l.Len()); } } else { TruePositives ++; } } if ((lHat.Len() == 0 or TruePositives == 0) and Which == fScore) { return 1.0; } TFlt precision = (1.0*TruePositives)/lHat.Len(); TFlt recall = (1.0*TruePositives)/l.Len(); if (Which == fScore) { return 1 - 2 * (precision*recall) / (precision + recall); } return LabelLoss; }