{"id":17998798,"url":"https://github.com/kingfengji/eforest","last_synced_at":"2025-03-26T06:31:19.890Z","repository":{"id":40439512,"uuid":"134068517","full_name":"kingfengji/eForest","owner":"kingfengji","description":"This is the official implementation for the paper 'AutoEncoder by Forest'","archived":false,"fork":false,"pushed_at":"2018-05-19T15:57:08.000Z","size":159,"stargazers_count":75,"open_issues_count":2,"forks_count":28,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-21T08:48:30.980Z","etag":null,"topics":["autoencoder","eforest","encoderforest","random-forest"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kingfengji.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-19T14:21:12.000Z","updated_at":"2024-11-23T09:52:30.000Z","dependencies_parsed_at":"2022-09-12T13:11:42.009Z","dependency_job_id":null,"html_url":"https://github.com/kingfengji/eForest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingfengji%2FeForest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingfengji%2FeForest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingfengji%2FeForest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingfengji%2FeForest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kingfengji","download_url":"https://codeload.github.com/kingfengji/eForest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245603659,"owners_count":20642862,"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":["autoencoder","eforest","encoderforest","random-forest"],"created_at":"2024-10-29T22:07:34.901Z","updated_at":"2025-03-26T06:31:19.306Z","avatar_url":"https://github.com/kingfengji.png","language":"Python","readme":"# eForest: A random forest based autoencoder.\n\nThis is the official clone for the implementation of encoderForest.(The University's webserver is unstable sometimes, therefore we put the official clone here at github)\n\nPackage Official Website: http://lamda.nju.edu.cn/code_eForest.ashx\n\nThis package is provided \"AS IS\" and free for academic usage. You can run it at your own risk. For other purposes, please contact Prof. Zhi-Hua Zhou (zhouzh@lamda.nju.edu.cn).\n\nDescription: A python implementation of encoderForest proposed in [1].\nA demo implementation of eForest library as well as some demo client scripts to demostrate how to use the code.\nThe implementation is flexible enough for modifying the model or fit your own datasets.\n\n**Reference: [1] J. Feng and Z.-H. Zhou. [AutoEncoder by Forest](http://lamda.nju.edu.cn/fengj/paper/aaai18eForest.pdf). In: Proceedings of the 32nd AAAI Conference on Artificial Intelligence (AAAI'18), New Orleans, Lousiana, USA, 2018.**\n\nATTN: This package was developed and maintained by Mr.Ji Feng(http://lamda.nju.edu.cn/fengj/) .For any problem concerning the codes, please feel free to contact Mr.Feng.（fengj@lamda.nju.edu.cn) or open some issues here.\n\n\n\n# Installation\n## Step 1: Create virtual envrionment\nThe eforest is based on a custom version of scikit-learn, in which we add some extra methods in the origin forest models.\\\nTo avoid confiction with other usage of the official version of scikit-learn, you need to create a seperate envirionment.\\\nIf you are using anaconda ( it's a must), you will need to run the following command.\n```\nconda create -n eforest python=3.5 anaconda\nsource activate eforest\npip uninstall scikit-learn\n```\n## Step 2: checkout the scikit-learn codes\nThe latest released version of sklearn until the code released is v0.19.1, you need to clone the code and check-out that version. That is, run the following command (you cannot install sklearn via pip/conda):\n```\ngit clone https://github.com/scikit-learn/scikit-learn.git\ncd scikit-learn\ngit checkout tags/0.19.1 -b 0.19.1\n```\n## Step 3: Merge eforest code (this repo) into scikit-learn and install it.\nExit the folder and go to the folder containing the package, run the following command.\n```\nsh copy_codes.sh\ncd scikit-learn\npython setup.py install\n```\nAnd that's it.\n\n# Usage\nCurrent supported model in sklearn includes:\n* Supervised Model\n    - sklearn.ensemble.RandomForestClassifier\n    - sklearn.ensemble.RandomForestRegressor\n    - sklearn.ensemble.ExtraTreesClassifier\n    - sklearn.ensemble.ExtraTreesRegressor\n* Unsupervised Model\n    - sklearn.ensemble.RandomTreesEmbedding\n\n## Simple Encode/Decode Demo\n```\nfrom sklearn.ensemble import RandomForestClassifier\nfrom keras.datasets import mnist\n(x_train, y_train), (x_test, y_test) = mnist.load_data()\nx_train = x_train.reshape((x_train.shape[0], -1))\nx_test = x_test.reshape((x_test.shape[0], -1))\nmodel = RandomForestClassifier(n_estimators=1000, max_depth=None, n_jobs=-1)\nmodel.fit(x_train, y_train)\nX_encode = model.encode(x_test)\nX_decode = model.decode(X_encode)\n```\n\n## API details of model.encode\n### Parameters\n* X [ndarray]\n    - shape = [n_samples, n_features]\n### Returns\n* X_encode [ndarray]\n    - shape = [n_samples, n_trees]\n    - X_encode[i, j] represent the leaf index for the j'th tree for the i'th sample\n\n## API details of model.decode\n### Parameters\n* X_encode [ndarray]\n    - shape = [n_samples, n_trees]\n* sample_method [str, default='minimal']\n    - If sample_method == 'minimal':\n    - The value of each dimension of the decoded result is determined by the minimal value defined by the corresponding MCR, you can define your own sample method as well.\n    - MCR (Maximal-Compatible Rule) is the rule defined by the decison paths of X, checkout the paper for more details.\n* null_value [float, default=0]\n    - The value used to replace nan value when the MCR is not defined for the particular attribute.\n### Returns\n* X_decode [ndarray]\n    - shape = [n_samples, n_feautres]\n\n\n# More Examples \n## MNIST AutoEncoding Example\nThe following scripys will display the autoencoding result for MNIST dataset. \\\nThe first row (origin) is the origin images. \\\nThe second row (supervised) is the decoded result of eforest in supervised setting. \\\nThe third row (unsupervised) is the decoded result of eforest in unsupervised setting.\n```\npython exp/mnist_autoencoder.py\n```\n![mnist autoencoder](figures/mnist.jpg)\n## CIFAR10 AutoEncoding Example\nRun the following scripts, It will display the autoencoding result for CIFAR10 dataset\n```\npython exp/cifar10_autoencoder.py\n```\n![cifar10 autoencoder](figures/cifar10.jpg)\n\n\n**For citation purpose, please cite:**\\\nJ. Feng and Z.-H. Zhou. [AutoEncoder by Forest](http://lamda.nju.edu.cn/fengj/paper/aaai18eForest.pdf). In: Proceedings of the 32nd AAAI Conference on Artificial Intelligence (AAAI'18), New Orleans, Lousiana, USA, 2018.  \n\nHappy Hacking.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingfengji%2Feforest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkingfengji%2Feforest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingfengji%2Feforest/lists"}