Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

Here is the C# version of that snippet, assuming the existence of such libraries.

    var mins = X.Min(axis: 0);
    var maxs = X.Max(axis: 0);
    var idxs = np.Random.Choice(Enunmeration.Range(this.dim), this.dim-this.exlevel-1, replace: false);  // Pick the indices for which the normal vector elements should be set to zero acccording to the extension level.
    this.n = np.Random.Normal(0,1, this.dim);                             // A random normal vector picked form a uniform n-sphere. Note that in order to pick uniformly from n-sphere, we need to pick a random normal for each component of this vector.
    this.n[idxs] = 0;
    this.p = np.Random.Uniform(mins,maxs);                               // Picking a random intercept point for the hyperplane splitting data.
    var w = (X-this.p).Dot(this.n) < 0;                                      // Criteria that determines if a data point should go to the left or right child node.
    return new Node(X, this.n, this.p, e,
                left: this.MakeTree(X[w],e+1,l),
                right: this.MakeTree(X[~w],e+1,l),
                node_type: "inNode")
There is nothing about Python flexibility there other than a possible missing library implementation.


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: