Package: intersectionalipy
IntersectionalipyBackgroundAs debates about race, privilege, and cultural power continue to rage through our society,intersectionalityhas become simultaneously one of the most important and least well understood paradigms of thought in the modern political environment. The term itself, originally coined byKimberlé Williams Crenshaw, refers to ways in our overlapping identities influence our experiences of privilege and oppression.At its core, intersectionality is a framework for describing how people's different identities interact and amplify each other in ways that not are simply described by single categories like race or gender. For instance, a Black woman might experience the condition of her race¹ differently than a Black man would. The theory aims to describe the different "vectors of oppression" that a person might experience as a result of their identities. At a community level, this results in the idea of a"matrix of domination"that describes the relationships between different strata of society.In order to formalize this theory mathematically, we must clear up some potentially confusing terminology. We can consider the notion of oppressionto be a function over a set of identity valuesdrawn from a set of identity spaces. While the output space of the oppression fuction may itself be mulitdimensional–economic, social, political, etc.–the term "vectors of oppression" is a bit of a misnomer as oppression does not properly constitue avector space(for instance, addition of oppressions is not guaranteed to be commutative). Indeed, much of the work of intersectionality involves considering maps between different identities (not to be confused with the standardidenity mapconcept in mathematics, e.g. theidentity matrixin thegeneral linear group) to understand the oppression a person might experience if their identity were to be different (i.e.,). In this formalism, we also realize that the "matrix of domination" is not properly a matrix, as it does not describe a linear transformation between identity spaces (it is more properly abivectorof domination).While it might seem a trivial observation that people from different backgrounds experience the world differently, the theory of intersectionality makes straightforward but strong mathematical claims that have significant implications in the realm of statistical analysis. Namely, intersectionality asserts that oppressioncannotgenerally be expressed as a linear combination of functions over the individual subspaces (that is, functions of the form). Rather, oppression must be considered as a general, possibly non-linear, function over the entire identity space,.This leads to natural, practical consequences in the practices ofstatisticsandeconometrics. Most directly, it is frequent practice to runregressionswhich attempt to control for the effects of different identities through the use ofindicator/dummy variables(or one-hot encodings in the machine learning parlance). Typically these indicator variables are produced at the level of a single identity space. Such a formalism precludes the ability to capture the kind of non-linear interactions between identities that are the focus of intersectional analysis. Instead, intersectionality prescribes that these indicator variables should be constructed on theCartesian productof the identity spaces.An aside: this distinction is especially crucial for regression and other linear approaches that are dominant in the social sciences. However, in the discipline ofmachine learning(ML) more flexible models are common (likerandom forestsandneural networks) which have the ability, in principle, to express arbitrary non-linear relationships. Thus, a valid ML approach is to use a non-linear model with the standard indicator identity variables. (We should be careful to distinguish this ML approach from another "ML" approach–that ofMarxism-Leninism, which would impose that oppression be a univariate function of class², itself possibly a function of identity.)While the construction of indicator variables from the Cartesian product space is a powerful prescription, it doesn't come for free: namely, this construction invites thecurse of dimensionality. If we incorporate even a relatively small number of identity spaces like race, gender, and sexual orientation, we could easily end up with 100 indicator variables. Unless we are dealing with a large number of observations in our dataset, this in turn can lead tooverfitting, or in the extreme case to more fitting parameters than observations and thusno unique solution. Therefore,intersectional analysis must carefully balance the inclusion of these interaction terms with the concern of statistically significant, generalizable results.Intersectionalipy is a package forPythonthat aims to make this kind of intersectional analysis easier for researchers.¹Not to be confused with arace condition, which is a rarely a concern in synchronous Python code due to theglobal interpreter lock.²Function of class here meaning class in the political sense; intersectionalipy does not register anymethodsto existing Python classes.UsageIntersectionalipy provides a clear, straightforward API that aims to simplify performing intersectional analysis in the scientific python stack. The package is built to work withpandasDataFrames, which can plugged directly into statistical analysis packages likestatsmodelsorscikit-learn.Intersectionalipy operates on DataFrames where some of the columns encode categorical identity information. Users pass in the dataframe and the names of those identity columns, and intersectionalipy returns a new dataframe where all identity columns have been replaced by a complete set of identity indicator variables.For example:>>>importintersectionalipyasi14py,pandasaspd>>>df=pd.DataFrame({...'data':[0.2,0.7,0.9],...'gender':['female','male','female'],...'race':['white','Black','Asian'],...'sexuality':['gay','straight','queer'],...})>>>dfdatagenderracesexuality00.2femalewhitegay10.7maleBlackstraight20.9femaleAsianqueer>>>i14py.intersectionalize(df,['race','sexuality','gender'])data(Asian,queer,female)(Black,straight,male)(white,gay,female)00.200110.701020.9100If using all identity columns together results in too many indicator variables for a meaningful regression, researchers can choose to limit the set of identity interations they explore through multiple calls to intersectionalipy:df=i14py.intersectionalize(df,['race','religion'])df=i14py.intersectionalize(df,['sexuality','gender'])Practicioners may want to conduct apower analysis(as in statistical power, though the regression itself may be an analysis of cultural and political power) to decide on the right level of intersectionality.NB: When running a regression oncategorical values with indicator variables, it is typical practice to useindicator regressors to prevent overfitting. This is typically done by choosing one category to leave out, and then the coefficients on all other indicator variables are interpreted with respect to that left out category. Because the sensible choice of a base category often depends on the detailed nature of the problem, intersectionalipy leaves this choice to the researcher and returns allindicators.Installationpip install intersectionalipy