Saravanan666/pypi-org huggingface dataset:
Package: treegrad
TreeGradTreeGradimplements a naive approach to converting a Gradient Boosted Tree Model to an Online trainable model. It does this by creating differentiable tree models which can be learned via auto-differentiable frameworks.TreeGradis in essence an implementation of Kontschieder, Peter, et al. "Deep neural decision forests." with extensions.To installpython setup.py installor alternatively from pypipip install treegradRun tests:python -m nose2@inproceedings{siu2019transferring,
  title={Transferring Tree Ensembles to Neural Networks},
  author={Siu, Chapman},
  booktitle={International Conference on Neural Information Processing},
  pages={471--480},
  year={2019},
  organization={Springer}
}Link:https://arxiv.org/abs/1904.11132Usagefromsklearn.importtreegradastgdmod=tgd.TGDClassifier(num_leaves=31,max_depth=-1,learning_rate=0.1,n_estimators=100,autograd_config={'refit_splits':False})mod.fit(X,y)mod.partial_fit(X,y)RequirmentsThe requirements for this package are:lightgbmscikit-learnautogradFuture plans:Add implementation for Neural Architecture search for decision boundary splits (requires a bit of clean up - TBA)Implementation can be done quite trivially using objects residing intree_utils.py- Challenge is getting this working in a sane manner withscikit-learninterface.GPU enabled auto differentiation framework - seenotebooks/for progress off Colab for Tensorflow 2.0 portsupport xgboost/lightgbm additional features such as monotone constraintsSupportRegressorMixinResultsWhen decision splits are reset and subsequently re-learned, TreeGrad can be competitive in performance with popular implementations (albeit an order of magnitude slower). Below is a table showing accuracy on test dataset on UCI benchmark datasets for Boosted Ensemble models (100 trees)DatasetTreeGradLightGBMScikit-Learn (Gradient Boosting Classifier)adult0.8600.8730.874covtype0.8320.8350.826dna0.9500.9490.946glass0.7660.8130.719mandelon0.8820.8810.866soybean0.9360.9360.917yeast0.5910.5730.542ImplementationTo understand the implementation ofTreeGrad, we interpret a decision tree algorithm to be a three layer neural network, where the layers are as follows:Node layer, which determines the decision boundariesRouting layer, which determines which nodes are used to route to the final leaf nodesLeaf layer, the layer which determines the final predictionsIn the node layer, the decision boundaries can be interpreted asaxis-paralleldecision boundaries from your typical Linear Classifier; i.e. a fully connected dense layerThe routing layer requires a binary routing matrix to which essentially the global product routing is appliedThe leaf layer is your typical fully connected dense layer.This approach is the same as the one taken by Kontschieder, Peter, et al. "Deep neural decision forests."
Package: tree-guardian
Tree GuardianTrack the changes into the filesystem and trigger callback on changes
detecting.Getting StartedInstallationpipinstalltree-guardianUsage (Python)Observe the changes into your project.fromtree_guardianimportobserve# Target function to triggerdefcb():fromtimeimporttimeprint('[{}] Changes detected...'.format(time()))observe(cb)# Run observerRun in background.fromtimeimportsleepfromthreadingimportEventfromtree_guardianimportobserve# Target function to triggerdefcb():fromtimeimporttimeprint('[{}] Changes detected...'.format(time()))event=Event()observe(cb,run_async=True,event=event)# Run observer# Type your code below...try:sleep(10)# Run for 10 seconds or until interruptedexceptKeyboardInterrupt:event.set()Usage (Cli)You can also use tree-guardian commands in shell. To make observe, run, for example:tree-guardian-observe--command='[YOUR SHELL COMMAND HERE]'This command supports the following params:usage:tree-guardian-observe[-h][-d]-cCALLBACK[-pPATH][-e[EXCLUDE...]]Observedirectoryandtriggercallbackonchangedetection

optionalarguments:-h,--helpshowthishelpmessageandexit-d,--debugrunobserveondebugmode;italsodisplaysalltrigger-commandoutput-c[CALLBACK_COMMAND...],--cmd[CALLBACK_COMMAND...],--command[CALLBACK_COMMAND...],--callback[CALLBACK_COMMAND...],--callback-command[CALLBACK_COMMAND...]triggercommand-pPATH,--pathPATHtheobservablerootpath-e[EXCLUDE...],--exclude[EXCLUDE...]excludedfilesfromobserveCall it with--helpflag to get more details.tree-guardian-observe--help
Package: treeHandler
tree-handlerOS wrapper to grab specific/all files from all the subdirectories of the given folder, process
them with your algorithm and save the output retaining the same input structureInstallationYou can easily install the package usingpip install treeHandlerUsageThis package will help you to find all/specific files from the subdirectories of a given directory.
Thus you can process these files and save them retaining the complex tree structure.eg:
If you have a complex tree structured folder and you need to get all the
files from the folder, usefromtreeHandlerimporttreeHandlerth=treeHandler()fileTuple=th.getFiles('inputFolder')### fileTuple is a list of tuples with each tuple containing file names and their folder path### eg: [('image11.jpg', 'sampleData/folder1'),('image21.jpg', 'sampleData/folder2')]### If you need to filter specific file extensions eg: .jpg,.pngth.getFiles('inputFolder',['jpg','png'])### If you need case sensitive (only lowercase 'jpg')th.getFiles('inputFolder',['jpg'],caseSensitive=True)The output will be obtained instantly.AuthorsSreekiran A R-Senior Analytics Consultant, AI Labs, Bridgei2i Analytics Solutions-Github,StackoverflowLicenseThis project is licensed under the MIT License - see theLICENSE.mdfile for details
Package: tree-html
# Tree HTMLTree HTML renders an interactive directory structure in html from a local path on disk.
It can be run as a standalone python tool or it can be fed JSON output produced by runningtreeseparately somewhere else.
This tool was built on top of the [CodyHouse](https://github.com/CodyHouse/multi-level-accordion-menu) HTML/CSS codebase
for displaying files and directories neatly.See the example output from runningtree-htmlon this repo:![screenshot](tree-html-screenshot.png)## General usageIn the most common case,tree-htmlcan be run as a standalone tool on the current working directory as follows:`tree-html`A second use case involves supplyingtree-htmlwith the output json file obtained from runningtree -Jseparately.
This may be useful, for example, in cases where you are working on a different file system to the target path.
This can be achieved by using the-iflag; for example:`tree-html-ioutput-file-from-tree.json`The default output fromtree-htmlis a directory namedtree-html/which is generated in the current working directory.
This directory contains a file calledindex.html, which can be opened in any browser for display.
Note that this directory also contains some static assets that should always accompany the html file if the folder is to
be moved or shared.## Usage optionsTo execute the tool from a location other than the current working directory:`tree-html/path/to/different/cool-location`In the above case, it also might be desirable to specify a different top-level directory name to use in the output,
rather than the full path. This can be achieved as follows:`tree-html/path/to/different/cool-location-ncooler-location`To limit the output to only contain a given depth below the top-level directory, the-lflag can be used:` tree-l3  # limits the output to three levels below the parent and ignores anything deeper `Additional options may be supplied to customise the content and styling of the output file, such as using custom headings,
text descriptions, different colored themes and url links. Runtree-html –helpfor the complete set of available options.## InstallationInstall using pip:` pip installtree-html`Or if you prefer to use pipenv to automatically installtree-htmlinto a new isolated virtual environment:` pipenv install . `If you wish to develop this tool further then you should also install the development dependencies:` pipenv install--dev`If you would like to contribute, please either create a new branch or fork this repo and then submit a pull request.
All contributions are welcome.
Package: tree-influence
TreeInfluence: Influence Estimation for Gradient-Boosted Decision Treestree-influenceis a python library that implements influence estimation for gradient-boosted decision trees (GBDTs), adapting popular techniques such as TracIn and Influence Functions to GBDTs. This library is compatible with all major GBDT frameworks including LightGBM, XGBoost, CatBoost, and SKLearn.Installationpipinstalltree-influenceUsageSimple example usingBoostInto identify the most influential training instances to a given test instance:importnumpyasnpfromsklearn.datasetsimportload_irisfromsklearn.model_selectionimporttrain_test_splitfromlightgbmimportLGBMClassifierfromtree_influence.explainersimportBoostIn# load iris datadata=load_iris()X,y=data['data'],data['target']# use two classes, then split into train and testidxs=np.where(y!=2)[0]X,y=X[idxs],y[idxs]X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.1,random_state=1)# train GBDT modelmodel=LGBMClassifier().fit(X_train,y_train)# fit influence estimatorexplainer=BoostIn().fit(model,X_train,y_train)# estimate training influences on each test instanceinfluence=explainer.get_local_influence(X_test,y_test)# shape=(no. train, no. test)# extract influence values for the first test instancevalues=influence[:,0]# shape=(no. train,)# sort training examples from:# - most positively influential (decreases loss of the test instance the most), to# - most negatively influential (increases loss of the test instance the most)training_idxs=np.argsort(values)[::-1]Supported Estimatorstree-influencesupports the following influence-estimation techniques in GBDTs:MethodDescriptionBoostInTraces the influence of a training instance throughout the training process (adaptation of TracIn).TREXTrains a surrogate kernel model that approximates the original model and decomposes any prediction into a weighted sum of the training examples (adaptation of representer-point methods).LeafInfluenceEstimates the impact of a training example on thefinalGBDT model (adaptation of influence functions).TreeSimComputes influence via similarity in tree-kernel space.LOOLeave-one-out retraining, measures the influence of a training instance by removing and retraining without that instance.LicenseApache License 2.0.ReferenceBrophy, Hammoudeh, and Lowd.Adapting and Evaluating Influence-Estimation Methods for Gradient-Boosted Decision Trees. arXiv 2022.@article{brophy2022treeinfluence,
  title={Adapting and Evaluating Influence-Estimation Methods for Gradient-Boosted Decision Trees},
  author={Brophy, Jonathan, and Hammoudeh, Zayd, and Lowd, Daniel},
  journal={arXiv preprint arXiv:2205.00359},
  year={2022},
}
Package: tree-inspector
Inspector for Python objectsTree Inspector is a package to inspect generic Python object interactively as a tree structure.Trythesample html pageInstallIt is very simple to install Tree Inspector. Just dopip install tree-inspectorUsageUsing Tree Inspector is even simpler.fromtree_inspectorimportdump_tree_to_filedump_tree_to_file(any_object,'/tmp/outfile.html',name='Optional Name')Configuring the tree viewTo be continued
Package: treeinterpreter
Package for interpreting scikit-learn’s decision tree and random forest predictions.
Allows decomposing each prediction into bias and feature contribution components as described inhttp://blog.datadive.net/interpreting-random-forests/. For a dataset withnfeatures, each prediction on the dataset is decomposed  asprediction = bias + feature_1_contribution + ... + feature_n_contribution.It works on scikit-learn’sDecisionTreeRegressorDecisionTreeClassifierExtraTreeRegressorExtraTreeClassifierRandomForestRegressorRandomForestClassifierExtraTreesRegressorExtraTreesClassifierFree software: BSD licenseDependenciesscikit-learn 0.17+InstallationThe easiest way to install the package is viapip:$ pip install treeinterpreterUsagefrom treeinterpreter import treeinterpreter as ti
# fit a scikit-learn's regressor model
rf = RandomForestRegressor()
rf.fit(trainX, trainY)

prediction, bias, contributions = ti.predict(rf, testX)Prediction is the sum of bias and feature contributions:assert(numpy.allclose(prediction, bias + np.sum(contributions, axis=1)))
assert(numpy.allclose(rf.predict(testX), bias + np.sum(contributions, axis=1)))More usage examples athttp://blog.datadive.net/random-forest-interpretation-with-scikit-learn/.History0.1.0 (2015-07-22)First release on PyPI.
Package: treeio
======treeio======.. image:: https://img.shields.io/pypi/v/treeio.svg:target: https://pypi.python.org/pypi/treeio.. image:: https://img.shields.io/travis/yech1990/treeio.svg:target: https://travis-ci.org/yech1990/treeio.. image:: https://readthedocs.org/projects/treeio/badge/?version=latest:target: https://treeio.readthedocs.io/en/latest/?badge=latest:alt: Documentation StatusA pure python parser for tree data format IO* Free software: MIT license* Documentation: https://treeio.readthedocs.io.Features--------* TODOCredits-------This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template... _Cookiecutter: https://github.com/audreyr/cookiecutter.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage=======History=======0.0.0.dev0 (2018-09-06)------------------* First release on PyPI.
Package: treeio-achievements
treeio-achievements is a module for Tree.io (http://tree.io) that allows you to
distribute Achievements among the users.
It is completely integrated and even comes with a widget to dispay the last
three Achievements that were given out.InstallationSadly, the installation is pretty complex. This assumes you already have
Tree.io running.runpip installtreeio-achievementsaddachievementsto yourINSTALLED_APPSadd the following line to your urls.py:(r'^achievements/',include('achievements.urls')),runpython manage.py migrate achievementsAnd that should do the trick.Have fun!Author: Pascal Mouret
Package: treeish
TreeishSome functions to help with tree like (json-ish) python structures.Example Data>>>data=[{"item":"Preliminary Title","units":[{"item":"Chapter 1","caption":"Effect and Application of Laws","units":[{"item":"Article 1","content":'This Act shall be known as the "Civil Code of the Philippines." (n)\n',},{"item":"Article 2","content":"Laws shall take effect after fifteen days following the completion of their publication either in the Official Gazette or in a newspaper of general circulation in the Philippines, unless it is otherwise provided. (1a)\n",},],}],}]Setter of IDs>>>fromtreeishimportset_node_ids>>>set_node_ids(data)# all nodes in the tree will now have an `id` key, e.g.:{"item":"Article 1","content":'This Act shall be known as the "Civil Code of the Philippines." (n)\n',"id":"1.1.1.1."},Getter of Node by ID>>>fromtreeishimportget_node_id>>>get_node_id("1.1.1.1."){"item":"Article 1","content":'This Act shall be known as the "Civil Code of the Philippines." (n)\n',"id":"1.1.1.1."}Enables Limited Enumeration Per Layer>>>raw=[{"content":"Parent Node 1"},{"content":"Parent Node 2","units":[{"content":"Hello World!","units":[{"content":"Deeply nested content"},{"content":"Another deeply nested one"},],},{"content":"Another Hello World!"},],},]>>>fromtreeishimportLayers>>>Layers.DEFAULT(raw)# note the addition of the `item` key to the raw itemless data[{'content':'Parent Node 1','item':'I'},{'content':'Parent Node 2','units':[{'content':'Hello World!','units':[{'content':'Deeply nested content','item':1},{'content':'Another deeply nested one','item':2}],'item':'A'},{'content':'Another Hello World!','item':'B'}],'item':'II'}]Fetcher of Values>>>fromtreeishimporttest_fetch_values_from_key>>>list(test_fetch_values_from_key(data[0]),"item")["Preliminary Title","Chapter 1","Article 2","Article 1",]
Package: treekit
Library for Studying and Applying Tree Data StructureInstallationpip install treekitSample Usage>>> from treekit import binarytree
>>> bt1 = binarytree([13, 3, 14, 0, 4, None, None, None, 2, None, 7]) # data array in breadth-first order, see: https://en.wikipedia.org/wiki/Binary_tree#Arrays
>>> bt1.show() # this will create an output.html and open a tab in web browser to view it
>>> bt1.height
3
>>> bt1.inorder # bt.preorder # bt.postorder # bt.levelorder
[0, 2, 3, 4, 7, 13, 14]
>>> bt1.preorder
[13, 3, 0, 2, 4, 7, 14]
>>> bt1.diameter()
The sum of depths from the left and right subtrees of Node(3) is 4
4
>>> bt1.flatten(target="preorder", inplace=True)
>>> bt1.inorder
[13, 3, 0, 2, 4, 7, 14]
>>> bt1.preorder
[13, 3, 0, 2, 4, 7, 14]
>>> bt1.find_maximum_path_sum()
(43, Node(13))>>> from treekit import binarytree
>>> bt2 = binarytree()
>>> bt2.compact_build([4, -7, -3, None, None, 8, -4, 9, -7, -4, None, 6, None, -1, -6, None, None, 0, 6, 7, None, 11, None, None, -1, -4, None, None, None, -2, None, -3])
>>> bt2.show() # this will create an output.html and open a tab in web browser to view it
>>> bt2.diameter()
The sum of depths from the left and right subtrees of Node(8) is 9
9>>> from treekit import tree
>>> t1 = tree()
>>> t1.remove_invalid_parenthese('()())a)b()))')
['((ab()))', '((a)b())', '(()ab())', '(()a)b()', '(())ab()', '()(ab())', '()(a)b()', '()()ab()']
>>> t1.Fibonacci_numbers(n=5, a=[0, 1])
>>> t1.Fibonacci_numbers(n=5, a=[0, 1], distinct=True)
>>> t1.Lucas_numbers(n=5)
>>> t1.Tribonacci_numbers(n=8, distinct=True)
>>> t1.Fibonacci_numbers_generalized(n=15, a=[0]*7+[1], distinct=True)
>>> t1.word_break_DFS(s = "catsanddog", wordDict = ["cats", "dog", "sand", "and", "cat"])
>>> t1.word_break_BFS(s = "catsanddog", wordDict = ["cats", "dog", "sand", "and", "cat"])
>>> t1.climbing_stairs(n_steps = 8)
>>> t1.coin_change(coins = [3, 5], amount = 12)
>>> t1.coin_change(coins = [1, 2, 3], amount = 6)
>>> t1.decode_ways(s = "11106")>>> from treekit import tree
>>> t2 = tree()
>>> t2.tree_traversals_summary()
>>> t2.validate_IP_address()>>> from treekit import bst
>>> bst1 = bst(h=4)
>>> bst1.show()>>> from treekit import heap # Max Heap
>>> from random import randint
>>> array = [randint(-100, 100) for x in range(30)]
>>> maxheap1 = heap(array)
>>> maxheap1.array
>>> maxheap1.show()Screenshot 1: Binary Search Tree, height = 4Screenshot 2: DFS Search Space for Removing Invalid ParenthesesScreenshot 3a: Computation Space for Fibonacci Numbers (n=5, order=2)Screenshot 3b: Computation Space for Fibonacci Numbers Generalized (n=15, order=8)Screenshot 4: DFS Search Space for Work BreakScreenshot 5: Max Heap
Package: treelock
treelockFast read/write sub-tree locking for asyncio Python. Suitable for large trees, when it's not feasible or desired to have the entire tree in memory at once.Inspired by the work ofRitik Malhotra.InstallationpipinstalltreelockUsageEach instance ofTreeLockis callable, and returns an asynchronous context manager. In order to acquire a read (shared) lock on the sub-trees with root nodes in the iterableread_roots; and to acquire a write (exclusive) lock of the sub-trees with root nodes in the iterablewrite_roots, you must pass them to the instance ofTreeLock:fromtreelockimportTreeLocklock=TreeLock()asyncdefaccess(read_roots,write_roots):asyncwithlock(read=read_roots,write=write_roots):# access the sub-treesThe lock isnotre-entrant: the same task attempting to enter multiple context managers with incompatible sub-trees will deadlock. Hence the locks for all the required sub-trees must be requested up-front.A typical use-case will be for read/write (shared/exclusive) locking of a path in a filesystem hierarchy. For example, if treating S3 as a filesystem, but allowing what-whould-be non-atomic operations on folders.For example, you could definedelete,write,rename,copyandreadoperations on folders at certainpaths, e.g. instances ofPurePosixPath. A read lock of such a path should allow reads of the corresponding folder, but block all operations that would change it. A write lock should prevent all other access to that folder. You can do this usingTreeLock, noting that each path is in fact a node in the tree of all possible paths.fromtreelockimportTreeLocklock=TreeLock()asyncdefdelete(path):asyncwithlock(read=[],write=[path]):...asyncdefwrite(path,...):asyncwithlock(read=[],write=[path]):...asyncdefrename(path_from,path_to):asyncwithlock(read=[],write=[path_from,path_to]):...asyncdefcopy(path_from,path_to):asyncwithlock(read=[path_from],write=[path_to]):...asyncdefread(path):asyncwithlock(read=[path],write=[]):...There is more information on this usage, as well as details of the underlying algorithm, athttps://charemza.name/blog/posts/python/asyncio/s3-path-locking/.Required properties of the nodesThese are a subset of the properties ofPurePosixPath.Each defines the__cmp__and__hash__methods. These are used for a dictionary internally, so__hash__must be reasonable enough to to acheive constant-time behaviour.Each must define the__lt__method. This must be well-behaved, i.e. defines a total order between all possible nodes, otherwise deadlock can occur.Each has a propertyparentsthat is an iterator to theancestorsof the node, indecreasingorder according to__lt__. This is a slightly mis-named property, but this is consistent with PurePosixPath.Note that a node does not need to be aware of its child nodes. This makesTreeLocksuitable for locking sub-trees below a node without knowledge of the descendants of that node.Fast locking and unlockingThe number of operations to lock or unlock a node only depends on the ancestors of a node. Specifically, it does not increase as the number of descendants increase, nor does it increase with the number of locks currently being held.Running testspythonsetup.pytest
Package: treelogger
TreeloggerThis package adds structure to your application logs by creating a tree structure for functions that execute within functions.These nested functions can be very troublesome to troubleshoot using a regular logger, but by using the tree logger, you can easily see the chain of events and drill down to where the error occurs.Below is an example of what the tree would look like. The example shows how output of a function can be nested to the appropriate level.Function Stand_Up 
-"Begin Standing Up" 
--Function Move_Legs
---"Moving Legs" 
----Function Check_Balance
-----"Balance is Good"
----Finish Check_Balance
---"Leg Movement Sucessful"
-- Finish Move_Legs 
-"Stand Up took 1 Second(s)" 
Finish Stand_upTo begin tree logging, import the tree object and treewrap decorator into your modules.#test.py 

from treelogger import tree, treewrap 


@treewrap()
def showthis(value):
    tree.log(value)

    return

@treewrap()
def nest(value):

    tree.log('Nesting a value of %i' % value)

    showthis(value)

    tree.log('Nesting a value of %i + 1' % value)

    showthis(value + 1)You can then import things from your modules into one or more main modules. In the main module, use the tree = TreeLogger() form to create a logging instance.The TreeLogger class instance is a global instance (kind of like sys.stdout) and all of your modules that imported tree will send their logs to the global tree. When defining the global tree, it has 2 default outputs: stdout and text file.#main.py
from test import showthis, nest
from treelogger import tree, TreeLogger

tree = TreeLogger()
nest(123)

tree.close_log()Running main.py would give you the output below.<?xml version="1.0" ?>
<log>
	<nest>
		<msg>  Nesting a value of 123  </msg>
		<showthis>
			<msg>  123  </msg>
		</showthis>
		<msg>  Nesting a value of 123 + 1  </msg>
		<showthis>
			<msg>  124  </msg>
        </showthis>
	</nest>
</log>As you can see, functions become nested and so do the logging messages for the functions. The resulting XML file can be searched using Xpath or visualized using an XML visualizer.A common mistake is to use the treewrap without the (). Unlike other decorators, the brackets are necessary for properly returning values from the decorated function.