/// <summary> /// Learns a decision tree from the provided observations and targets but limited to the observation indices provided by indices. /// Indices can contain the same index multiple times. Weights can be provided in order to weight each sample individually /// </summary> /// <param name="observations"></param> /// <param name="targets"></param> /// <param name="indices"></param> /// <param name="weights">Provide weights inorder to weigh each sample separetely</param> /// <returns></returns> public BinaryTree Learn(F64Matrix observations, double[] targets, int[] indices, double[] weights) { using (var pinnedFeatures = observations.GetPinnedPointer()) { return(Learn(pinnedFeatures.View(), targets, indices, weights)); } }
public void ArrayExtensions_IndexedCopy_ColumnView_Interval() { var values = new double[] { 0, 10, 20, 30, 40, 50 }; var matrix = new F64Matrix(values, 6, 1); var indices = new int[] { 1, 1, 2, 2, 2, 5 }; var destination = new double[values.Length]; var interval = Interval1D.Create(1, 5); using (var ptr = matrix.GetPinnedPointer()) { var view = ptr.View().ColumnView(0); indices.IndexedCopy(view, interval, destination); var expected = new double[] { 0, 10, 20, 20, 20, 0 }; CollectionAssert.AreEqual(expected, destination); } }