5

I've used SPSS to generate a CHAID tree.It does an automatic binning of continuous variables and returns Chi-squared value and Degrees of freedom which is not found in the summary function of R.Below is a partial sample output.

    Node    0               1               Total        PC Parent  Variable    Sig.a   Chi-Square  df  Split Values
        N   Percent      N  Percent        N    Percent                         
    0   148025  84.0%   28111   16.0%   176136  100.0%   0                      
    1   102390  93.9%   6643    6.1%    109033  61.9%    0    0     SALES1      0.000   42991.370   4   <= .000
    2   12600   91.3%   1194    8.7%    13794   7.8%     0    0     SALES1      0.000   42991.370   4   (.000,149.990]
    3   15140   83.7%   2942    16.3%   18082   10.3%    0    0     SALES1      0.000   42991.370   4   (149.990,1044.000]

What R returns is this:

https://stackoverflow.com/questions/32739093/what-are-the-available-chaid-summary-functions-in-r

I've found ways to tap into the tree output and play around with it like this example:

chaid regression tree to table conversion in r

Are there functions to get a SPSS kind of output in R or python or must it all be done manually with the partykit package in R?

Community
  • 1
  • 1

2 Answers2

3

I recently wrote an open-source package in python for CHAID here

Rambatino
  • 4,716
  • 1
  • 33
  • 56
  • I am facing issues while installing. extern "Python": function Cryptography_locking_cb() called, but @ffi.def_extern() was not called in the current subinterpreter. Returning 0. – harsha Feb 28 '18 at 15:37
  • I literally have no idea how I'm meant to solve that. If you have an issue create an issue on github, but you'll have to detail all the relevant package versions/operating system/commands etc... – Rambatino Mar 02 '18 at 14:30
  • Dude, is there any particular reason to not follow the .fit & .predict way as in sklearn ? – Tom Nov 03 '22 at 18:41
  • It was never written to predict - it gave an estimate of how good the fit was on the data given. It should be trivial to write those functions – Rambatino Nov 04 '22 at 12:54
0

Did you try CHAID package from r-forge link? It does well in performing CHAID analysis. However, all the variables need to be categorical / factors in order for it to work.

greenhorntechie
  • 386
  • 2
  • 6
  • 13