Skip to main content

A CHAID tree building algorithm

Project description

========================================
Chi-Squared Automatic Inference Detection
========================================

This package provides a python implementation of the Chi-Squared Automatic Inference Detection (CHAID) decision tree. More details can be found here_.


Installation
------------

CHAID is distributed via pypi_ and can be installed like:

.. code-block:: bash

pip install CHAID


Creating a Tree
---------------

.. code-block:: python

import CHAID from CHAID

pandas_data_frame = ...
independent_variable_columns = ['a', 'b', 'c']
dep_variable = ['d']
CHAID.from_pandas_df(df, independent_variable_columns, dep_variable)

Running from the Command Line
-----------------------------

You can play around with the repo by cloning and running this from the command line:

.. code-block:: bash

python3 -m CHAID CHAID/data/titanic.csv survived sex embarked --max-depth 4 --min-samples 2 --alpha-merge 0.05

It calls the `print_tree()` method, which prints the tree to terminal:

.. code-block:: bash

([], {'1': 500.0, '0': 809.0}, embarked, 1.0, 0.31731050786291404)
├── (['C', 'Q'], {'1': 194.0, '0': 199.0}, None, None, 1)
└── (['S', '<missing>'], {'1': 306.0, '0': 610.0}, None, None, 1)

To get a LibTree object, call to_tree() on the CHAID instance

.. _here: http://www.python.org/
.. _pypi: https://en.wikipedia.org/wiki/CHAID

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

CHAID-0.0.7.tar.gz (6.0 kB view details)

Uploaded Source

File details

Details for the file CHAID-0.0.7.tar.gz.

File metadata

  • Download URL: CHAID-0.0.7.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for CHAID-0.0.7.tar.gz
Algorithm Hash digest
SHA256 e763b6b1407983cb75b67da96042c954850a779ad4a50dc9fa8d804660f85b42
MD5 62e53f2212a0dc62f01ae8f757d49d6c
BLAKE2b-256 4dbdabfce7231b5d7ccb3c180d3970bf96bebb3d9013ea19b05cec36e46672f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page