Questions tagged [bins]
235 questions
4
votes
1 answer
LightGBM fit throws "ValueError: Circular reference detected" with categorical feature from pd.cut
I have been using with great satisfaction lightGBM models, as I have big datasets with tens of features and million of rows, with lots of categorical columns.
I like a lot the way lightGBM can get a pandas dataframe with categorical features…

Marcello
- 327
- 1
- 2
- 11
4
votes
1 answer
Customizing bin widths in plotly's histogram function in R
I have a dataset that dates and call volume per day. When I plotted them using the plotly R package, all except for 1 of them had each date separated into a different bin. However, this one tricky subset of the data instead grouped bins into 2 day…

Joshua Barnes
- 43
- 1
- 6
4
votes
2 answers
Number of bars in histogram - R
I have two problems with the histogram I'm making: I'm trying to generate an histogram in R, using the function hist(), for a frequency distribution of a numeric (interval) variable, which ranges from 0 to 10. The plot I'm aiming for should generate…

Mauricio Salgado
- 51
- 1
- 1
- 4
4
votes
1 answer
How to extract the fundamental frequency from cepstrum?
After applying a FFT, I get a spectrum with multiple frequency bins. How to get the fundamental frequency from this spectrum using the cepstral method?
I've researched a lot, tryed a lot of codes and asked three times on stackoverflow (wich helped a…

Lucas Speranza
- 149
- 1
- 3
- 5
4
votes
1 answer
How to choose number of bins in numpy.histogram?
If I use histogram of matplotlib , I can choose the number of bins.
But how can I choose the number of bins at histogram of numpy?
import matplotlib.pyplot as plt
import numpy as np
array = [1,3,4,4,8,9,10,12]
range = int((max(array)) -…

twi
- 127
- 1
- 3
- 8
4
votes
1 answer
Extending the range of bins in seaborn histogram
I'm trying to create a histogram with seaborn, where the bins start at 0 and go to 1. However, there is only date in the range from 0.22 to 0.34. I want the empty space more for a visual effect to better present the data.
I create my sheet with…

Jul
- 173
- 3
- 3
- 7
4
votes
1 answer
Label histogram by bins matplotlib
I have a histogram in which I want to label the x-axis by bins. The histogram is plotted as a log log graph, but the bins are very specific. The graph:
The bins:
bins = [0, 0.035, 0.07, 0.15, 0.5, 1, 3, 10, 40]
Is there any way I can do this? I…

Natalie
- 447
- 1
- 4
- 16
4
votes
2 answers
Creating 2D bins in R
I have coordinate data in R, and I would like to determine a distribution of where my points lie. The entire space of points is a square of side length 100.
I'd like to assign points to different segments on the square, for example rounded to the…

WeakLearner
- 918
- 14
- 26
4
votes
3 answers
makings a bins column with dates in python
In python i have data that looks like this with 500.000 rows :
TIME count
1-1-1900 10:41:00 1
3-1-1900 09:54:00 1
4-1-1900 15:45:00 1
5-1-1900 18:41:00 1
4-1-1900 …

camiel1985
- 53
- 1
- 5
4
votes
2 answers
cut several variables, using several different number of bins for each variable
I have a dataset which looks like this:
ID a b
ID1 0.1 20.3
ID2 0.2 21.6
ID3 1.2 1.5
etc.
I would like to group these values into equal-sized groups. This can be done with:
data$bin1 <- as.numeric(cut2(data$b,g=50))
This takes the values in…

Hill
- 89
- 8
4
votes
1 answer
Python pyplot histogram: Adjusting bin width, Not number of bins
I have been able to make myself a pretty little histogram that looks like this:
I was able to produce the image with the following code:
import numpy as np
import matplotlib.pyplot as plt
plt.figure()
plt.axis([0, 6000, 0,…

Anna Reed
- 89
- 1
- 1
- 8
4
votes
0 answers
Hexbin in R ggplot - hexagons get bigger if data is too sparse
I'm generating a series of hexbin plots for use in an animated GIF, and there are occasional frames that have a low density of data. The plots seem to create giant, misshapen hexagons.
Here is an example that works as…

user3641120
- 75
- 1
- 4
3
votes
3 answers
Histogram in logarithmic scale in gnuplot
I have to plot an histogram in logarithmic scale on both axis using gnuplot. I need bins to be equally spaced in log10. Using a logarithmic scale on the y axis isn't a problem. The main problem is creating the bin on the x axis. For example, using…

papafe
- 2,959
- 4
- 41
- 72
3
votes
1 answer
Pandas cut and specifying specific bin sizes
I have just been playing with cut and specifying specific bin sizes but sometimes I was getting incorrect data in my bins.
What I want to do is bin data depending on where it falls in my Risk Impact matrix.
Below is the original code I used to…

twelsh37
- 189
- 3
- 13
3
votes
2 answers
How to count column values in ranges rather than bins?
I am trying to find out how to neatly count the number of values in a dataframe column that fall into multiple custom ranges. I realize binning is the common technique for this, but I am not sure that is what I am looking for here.
Let's say I have…

LostinSpatialAnalysis
- 565
- 5
- 22