kI'm trying to build a decision tree model on a dataset that only has categorical values, an example fragment of the dataset is below. My training dataset consists of 40 observations

  Repository   PrimaryLanguage   BuildTools  IntegrationRequired  Active
1 repo-name-1  Java              Maven        yes                 yes
2 repo-name-2  Python            setuptools   yes                 yes
3 repo-name-3  YAML              None         no                  yes
4 repo-name-4  Java              Gradle       yes                 yes
5 repo-name-5  Shell             None         no                  no

The goal is to determine if a repo requires integration based on what type of language, and build tools it uses or if it is even active.

r code to build the tree model -

ml <- rpart(IntegrationRequired~PrimaryLanguage + BuildTools + Active, data=train, control = rpart.control("minsplit" = 2), method='class')

But my tree generates very few branches, and it splits nodes based on entire column instead of values in that column. How do I fix this or I should look at other algorithms like kmeans? Any help is deeply appreciated.

Plot - enter image description here

  • $\begingroup$ You don't have much data, so there's a limit to what any algorithm can achieve. $\endgroup$
    – mkt
    Sep 3, 2022 at 8:59
  • $\begingroup$ "It splits nodes based on entire column instead of values in that column" This and related threads may be useful: stats.stackexchange.com/questions/534680/… $\endgroup$
    – mkt
    Sep 3, 2022 at 9:03
  • $\begingroup$ First, why post a table of example data instead of a reproducible example? Second, I see a reasonable tree as result and am not sure, what your desired output would look like. This tree classifies to 3% out of 40 cases with 1/40 = 0.025 = 3% so why would you want more branches? $\endgroup$
    – Bernhard
    Sep 3, 2022 at 9:13
  • $\begingroup$ I don't think the tree is using the 'Active' category to make the decision. My objective is to create something like this - towardsdatascience.com/…, maybe I need to take a better look at Gini index, I'll post the solution if I get it working, thanks $\endgroup$ Sep 3, 2022 at 22:42


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.