Skip to content
Advertisement

Tag: numpy

Linear regression plot on log scale in Python

I want to do linear regression to the data given by x and y. Everything seems to be fine when I use a linear plot, but when I want to plot it on a log scale the line does not look straight. I think I should divide the interval into finer grids rather than only six points. But I couldn’t

how do i remove rows from numpy array based on date?

i have a number of arrays with the following format: how do i remove the rows where the datetime > 2021-05-06 09:20 and < 2021-05-06 09:40 ? I have tried with np.delete: and np.where: but always get the error: SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers Edit in response to

Is there a way to speed up looping over numpy.where?

Imagine you have a segmentation map, where each object is identified by a unique index, e.g. looking similar to this: For each object, I would like to save which pixels it covers, but I could only come up with the standard for loop so far. Unfortunately, for larger images with thousands of individual objects, this turns out to be very

Add features to the “numeric” dataset whose categorical value must be mapped using a conversion formula

I have this dataset: This is the request: “Add the Mjob and Fjob attributes to the “numeric” dataset whose categorical value must be mapped using a conversion formula of your choice.” Does anyone knows how to do it? For example: if ‘at_home’ value become ‘1’ in Mjob, I want the same result in the Fjob column. Same categorical values must

How to implement a constrained linear fit in Python?

I’m trying to fit a linear model to a set of data, with the constraint that all the residuals (model – data) are positive – in other words, the model should be the “best overestimate”. Without this constraint, linear models can be easily found with numpy’s polyfit as shown below. example1 Is there an efficient way to implement a linear

calculate sum of squares with rows above

I have a dataset that looks like this: I want to iterate through each row and calculate a sum of squares value for each row above (only if the Type matches). I want to put this value in the X.sq column. So for example, in the first row, there’s nothing above. So only (-1.975767 x -1.975767). In the second row,

Advertisement