{"id":13413376,"url":"https://github.com/malaschitz/randomForest","last_synced_at":"2025-03-14T19:32:13.430Z","repository":{"id":47721444,"uuid":"154625349","full_name":"malaschitz/randomForest","owner":"malaschitz","description":"Random Forest implementation in golang","archived":false,"fork":false,"pushed_at":"2024-02-28T21:50:33.000Z","size":11419,"stargazers_count":44,"open_issues_count":1,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-07-31T20:52:16.421Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/malaschitz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-25T07:05:29.000Z","updated_at":"2024-06-30T05:45:17.000Z","dependencies_parsed_at":"2024-06-18T22:53:33.233Z","dependency_job_id":"d3d6a87f-efab-4a2d-b2e1-72a1f164df9c","html_url":"https://github.com/malaschitz/randomForest","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malaschitz%2FrandomForest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malaschitz%2FrandomForest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malaschitz%2FrandomForest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malaschitz%2FrandomForest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/malaschitz","download_url":"https://codeload.github.com/malaschitz/randomForest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243635423,"owners_count":20322936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:38.911Z","updated_at":"2025-03-14T19:32:12.379Z","avatar_url":"https://github.com/malaschitz.png","language":"Go","readme":"GoDoc: https://godoc.org/github.com/malaschitz/randomForest\n\nTest: \n```go\ngo test ./... -cover -coverpkg=.  \n```\n\n# randomForest\n[Random Forest](https://en.wikipedia.org/wiki/Random_forest) implementation in golang. \n\n## Simple Random Forest\n\n```go\n\txData := [][]float64{}\n\tyData := []int{}\n\tfor i := 0; i \u003c 1000; i++ {\n\t\tx := []float64{rand.Float64(), rand.Float64(), rand.Float64(), rand.Float64()}\n\t\ty := int(x[0] + x[1] + x[2] + x[3])\n\t\txData = append(xData, x)\n\t\tyData = append(yData, y)\n\t}\n\tforest := randomForest.Forest{}\t\t\n\tforest.Data = randomforest.ForestData{X: xData, Class: yData}\n\tforest.Train(1000)\n\t//test\n\tfmt.Println(\"Vote\", forest.Vote([]float64{0.1, 0.1, 0.1, 0.1})) \n\tfmt.Println(\"Vote\", forest.Vote([]float64{0.9, 0.9, 0.9, 0.9}))\n```\n\n## Extremely Randomized Trees\n\n```go\n\tforest.TrainX(1000)\t\n```\n\n## Deep Forest\n\nDeep forest inspired by https://arxiv.org/abs/1705.07366\n\n```go\n    dForest := forest.BuildDeepForest()\n    dForest.Train(20, 100, 1000) //20 small forest with 100 trees help to build deep forest with 1000 trees\n```\n\n## Continuos Random Forest\n\nContinuos Random Forest for data where are still new and new data (forex, wheather, user logs, ...). New data create a new trees and oldest trees are removed.\n\n```go\nforest := randomForest.Forest{}\ndata := []float64{rand.Float64(), rand.Float64()}\nres := 1; //result\nforest.AddDataRow(data, res, 1000, 10, 2000) \n// AddDataRow : add new row, trim oldest row if there is more than 1000 rows, calculate a new 10 trees, but remove oldest trees if there is more than 2000 trees.\n```\n\n# Boruta Algorithm for feature selection\n\nBoruta algorithm was developed as package for language R. \nIt is one of most effective feature selection algorithm.\nThere is [paper](https://www.jstatsoft.org/article/view/v036i11) in Journal of Statistical Software.\n\nBoruta algorithm use random forest for selection important features.\n\n```go\n\txData := ... //data\n\tyData := ... //labels\n\tselectedFeatures := randomforest.BorutaDefault(xData, yData)\n\t// or randomforest.BorutaDefault(xData, yData, 100, 20, 0.05, true, true)\n```\n\nIn _/examples_ is example with [MNIST database](https://en.wikipedia.org/wiki/MNIST_database). \nOn picture are selected features (495 from 784) from images. \n\n![boruta 05](boruta05.png)\n\n# Isolation Forest\n\nIsolation forest is an anomaly detection algorithm. \nIt detects anomalies using isolation (how far a data point is to the rest of the data), rather than modelling the normal points. (wiki)\n\nTwo Isolation Forest methods are implemented. \nThe first is done as a statistic over the standard Random Forest. \nAfter the Random Forest is computed, per tree and per branch it calculates how deep each record is. \nThis is done over all trees, and the function returns the ranked statistics of the individual records. \nI recommend increasing the MaxDepth value.\n\n```go\n\tisolations, mean, stddev := forest.IsolationForest()\n\tfor i, d := range isolations {\n\t\tfmt.Println(i, d, mean, stddev)\n\t}\n```\nThe second method is done by https://en.wikipedia.org/wiki/Isolation_forest. \nIt gives different results than the first one. \nIn the isolation2.go example, it is used in a way that each label is evaluated separately.  \n\n```go\n\tforest := randomforest.IsolationForest{X: x}\n\tforest.Train(TREES)\n```\n\nResult for MINST are on image.\n\n![isolation forest](isolationForest.jpg)\n","funding_links":[],"categories":["机器学习","Machine Learning","Relational Databases"],"sub_categories":["SQL 查询语句构建库","Search and Analytic Databases","检索及分析资料库","Advanced Console UIs"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalaschitz%2FrandomForest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmalaschitz%2FrandomForest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalaschitz%2FrandomForest/lists"}