/// <summary> /// Requirements: /// (1) all the data points are indexed from 0 ... cDataCountsTotal /// (2) all data points belongs to one group are contingious /// </summary> /// <param name="groupId">maps a data point to its group ID</param> public DataGroups(LabelFeatureCore labelFeatureCore) { NumDataPoints = labelFeatureCore.NumDataPoint; List<int> listGroupId = new List<int>(); List<int> listStartIdx = new List<int>(); listGroupId.Add(labelFeatureCore.GetGroupId(0)); listStartIdx.Add(0); int curID = labelFeatureCore.GetGroupId(0); for (int i = 0; i < NumDataPoints; i++) { int nextID = labelFeatureCore.GetGroupId(i); if (nextID != curID) { listStartIdx.Add(i); listGroupId.Add(nextID); curID = nextID; } } groupCounts = listStartIdx.Count; dataGroups = new DataGroup[groupCounts]; for (int i = 0; i < groupCounts; i++) { dataGroups[i] = new DataGroup(); dataGroups[i].id = listGroupId[i]; dataGroups[i].iStart = listStartIdx[i]; if (i < groupCounts - 1) { dataGroups[i].cSize = listStartIdx[i + 1] - listStartIdx[i]; } else { dataGroups[i].cSize = NumDataPoints - listStartIdx[i]; } } }
public NDCGPairwise(LabelFeatureCore labelFeatureCore, LabelConverter labelConvert, DataPartitionType[] dataTypes, int ndcgAt, bool dropEmptyQueries, float scoreForEmptyQuery) : base(labelFeatureCore, labelConvert, dataTypes) { this.ndcg = new NDCG(dropEmptyQueries, scoreForEmptyQuery, ndcgAt); }
public Metrics(LabelFeatureCore labelFeatureCore, LabelConverter labelConvert, DataPartitionType[] dataTypes) { this.labelFeatureCore = labelFeatureCore; this.dataTypes = dataTypes; this.optimalID = -1; this.labels = new float[labelFeatureCore.NumDataPoint]; if (labelConvert != null) { for (int i = 0; i < labelFeatureCore.NumDataPoint; i++) { this.labels[i] = labelConvert.convert(labelFeatureCore.GetLabel(i)); } } else { for (int i = 0; i < labelFeatureCore.NumDataPoint; i++) { this.labels[i] = labelFeatureCore.GetLabel(i); } } this.dataSegments = new int[(int)DataPartitionType.cTypes][]; this.metricsCur = new float[(int)DataPartitionType.cTypes][]; for (int i = 0; i < (int)DataPartitionType.cTypes; i++) { metricsCur[i] = new float[SIZE]; } foreach (DataPartitionType dataType in dataTypes) { DataSet dataSet = labelFeatureCore.DataGroups.GetDataPartition(dataType); int[] dataSegment = dataSet.DataIndex; if (dataSegment != null) { dataSegments[(int)dataType] = dataSegment; } else { //we will fill in the non-existing data sections with 0 //throw new Exception("data partition does not exist"); } } this.results_list = new List<Result>(); }
public Metrics(LabelFeatureCore labelFeatureCore, DataPartitionType[] dataTypes) : this(labelFeatureCore, null, dataTypes) { }
//dataType==null <=> all the data are used in one partition public L_N(LabelFeatureCore labelFeatureCore, DataPartitionType[] dataTypes) : base(labelFeatureCore, dataTypes) { }
//dataType==null <=> all the data are used in one partition public ClassError(LabelFeatureCore labelFeatureCore, LabelConverter labelConvert, DataPartitionType[] dataTypes) : base(labelFeatureCore, labelConvert, dataTypes) { }