Questions tagged [gini]

The Gini coefficient (also known as the Gini index or Gini ratio) (/dʒini/ jee-nee) is a measure of statistical dispersion intended to represent the income distribution of a nation's residents, and is the most commonly used measure of inequality.

The Gini coefficient (also known as the Gini index or Gini ratio) (/dʒini/ jee-nee) is a measure of statistical dispersion intended to represent the income distribution of a nation's residents, and is the most commonly used measure of inequality.

72 questions
12
votes
2 answers

More efficient weighted Gini coefficient in Python

Per https://stackoverflow.com/a/48981834/1840471, this is an implementation of the weighted Gini coefficient in Python: import numpy as np def gini(x, weights=None): if weights is None: weights = np.ones_like(x) # Calculate mean…
Max Ghenis
  • 14,783
  • 16
  • 84
  • 132
9
votes
1 answer

What is the measure used for "importance" in the h2o random Forest

Here is my code: set.seed(1) #Boruta on the HouseVotes84 data from mlbench library(mlbench) #has HouseVotes84 data library(h2o) #has rf #spin up h2o myh20 <- h2o.init(nthreads = -1) #read in data, throw some away data(HouseVotes84) hvo <-…
EngrStudent
  • 1,924
  • 31
  • 46
6
votes
1 answer

How can I get Gini Coefficient in sklearn

I would like in sklearn package, Find the gini coefficients for each feature on a class of paths such as in iris data. like Iris-virginica Petal length gini:0.4 ,Petal width gini:0.4.
Ming
  • 71
  • 1
  • 1
  • 6
5
votes
0 answers

Custom loss function in Keras, how to deal with placeholders

I am trying to generate a custom loss function in TF/Keras,the loss function works if it is run in a session and passed constants, however, it stops working when compiled into a Keras. The cost function (thanks to Lior for converting it to TF) def…
Ilya
  • 561
  • 2
  • 17
5
votes
1 answer

Measuring income inequality using the R survey package

I'm working with American Community Survey microdata using the survey package, and am hoping to calculate some basic income inequality statistics. I've set up the following as my design: testsurv <- svrepdesign(data=test, repweights = test[,8:87],…
user115457
  • 51
  • 1
3
votes
2 answers

How to aggregate information from indefinite number of groups

How to aggregate information from indefinite number of groups in TSQL? E.g. we have a table with 2 columns - clients and regions. Clients Regions client1 45 client1 45 client1 45 client1 45 client1 43 client1 42 client1 41 client2 45 client2…
Alex Ivanov
  • 657
  • 1
  • 8
  • 17
3
votes
0 answers

calculate gini index for multiway split in R

I am trying to calculate the gini index in R. There is no problem to calculate the gini index for a binary decision tree as follows. gini_process <- function(classes,splitvar = NULL){ #Assumes Splitvar is a logical vector if…
3
votes
2 answers

What is the formula to calculate the gini with sample weight

I need your helps to explain how I can obtain the same result as this function does: gini(x, weights=rep(1,length=length(x))) http://cran.r-project.org/web/packages/reldist/reldist.pdf --> page 2. Gini Let's say, we need to measure the inocme of…
Thuy Nguyen Hong
  • 243
  • 1
  • 4
  • 11
2
votes
1 answer

Plotting multiple Gini Coefficients on the same graph

I am trying to plot the gini coefficient on a graph, showing different data for different variables (GDP_PPP and GDP_MER) to show the inequalities between gdp market exchange rate and gdp as gross national income. I am struggling to get both…
2
votes
1 answer

Generalized Gini with Weights in R

I want to calculate weighted generalized gini coefficients. CRAN distributes the "acid" package with a suitable function. What am i missing here? When weights are constant, the estimates of weighted.gini and sgini are equal given the parameter nu =…
2
votes
1 answer

How to calculate Gini coefficients for clustering

I have 5000 observations that are clustered into 10 clusters. Each cluster have 1000 true observations. The real life observations are 1000 in each cluster. However, after I have ran my clustering algorithm, it looks like this: Cluster #, true…
Oeyvind
  • 357
  • 6
  • 19
2
votes
1 answer

Why is Mean Decrease Gini in Random Forest dependent on population size?

I am using R package randomForest and to understand variable importance we can investigate varImpPlot which shows Mean decrease Gini. I have studied Random Forest in detail and am well aware of how this model works in detail, there is something that…
Raz89
  • 45
  • 1
  • 6
2
votes
0 answers

Gini coefficient calculation in R

I am using package Ineq in R to calculate Gini coefficent. From inspecting the source code (below), it is ordering vector x first before computing Gini. Example data: example_data = data.frame(SCORE_RANGE = c('100-200','201-300','301-…
Khiem Nguyen
  • 129
  • 1
  • 11
2
votes
0 answers

How to become the gini-index for each possible first split using CART in R (package rpart)

I have a huge Dataset with more than 125 variables. I am applying a CART (Classification and regression tree). What I am missing is a list of all possible first splits, with the referring gini-values (If you apply a CART in SAS, you become such a…
2
votes
2 answers

How to calculate Normalized Gini Coefficient in tensorflow

I am trying to calculate Normalized Gini Coefficient in tensorflow but am unable to do so. I have the below python code for the same executed in numpy but I want to implement it using tensorflow. If any ideas, please help. I will be having actual…
1
2 3 4 5