# Decision Trees and Political Party Classification

DevFeed: [Decision Trees and Political Party Classification](<https://devfeed.tech/articles/decision-trees-and-political-party-classification-40289.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2012/10/08/decision-trees-and-political-party-classification/>)

Published: 2012-10-08T14:49:21Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Algorithm](<https://devfeed.tech/topics/algorithm.md>), [Python](<https://devfeed.tech/topics/python.md>), [data](<https://devfeed.tech/topics/data.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [code](<https://devfeed.tech/tags/code.md>), [data](<https://devfeed.tech/tags/data.md>), [decision-trees](<https://devfeed.tech/tags/decision-trees.md>), [machine-learning](<https://devfeed.tech/tags/machine-learning.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [politics](<https://devfeed.tech/tags/politics.md>), [python](<https://devfeed.tech/tags/python.md>), [voting-prediction](<https://devfeed.tech/tags/voting-prediction.md>)

## AI overview

This tutorial explains how decision trees address limitations of k-nearest-neighbors when data is categorical, incomplete, or noisy. It presents a Python implementation applied to predicting the political party affiliation of US congressional members from their votes.

## Source excerpt

Last time we investigated the k-nearest-neighbors algorithm and the underlying idea that one can learn a classification rule by copying the known classification of nearby data points. This required that we view our data as sitting inside a metric space; that is, we imposed a kind of geometric structure on our data. One glaring problem is that there may be no reasonable way to do this. While we mentioned scaling issues and provided a number of possible metrics in our primer, a more common problem is that the data simply isn't numeric.