Categories
Mastering Development

Python speed up permutation of bits within 32Bit number

I’m interested in reordering the bits within a number, and since I want to do it several trillion times, I want to do it fast. Here are the details: given a number num and an order matrix order. order contains up to ~6000 lines of permutations of the numbers 0..31. These are the positions to […]

Categories
Artificial Intelligence (AI) Mastering Development

TensorFlow JS – saving min/max values alongside model and loading back in beside prediction data

I’m working on building a ML model using TensorFlow JS. New to JS and ML. I have a working model that makes decent predictions. However when I save the model and load it into a client side UI I also need the original min/max values to normalise to the same amount (I think this is […]

Categories
Mastering Development

Is it possible in Java to implement interfaces and their methods without using the keyword “implements”?

I have homework to do (actually my girlfriend :-D) and there are some restrictions on what I can and can’t do. In my NetBeans project folder there are two folders named "interfaces" and "homework". The folder "interfaces" contains interfaces and classes that are NOT allowed to edit, because said that to us xD. I am […]

Categories
Mastering Development

Calculating rolling correlations on time series

I have a tbl-df object and I need to calculate 22 days rolling correlations between the values in second and third column. This is the dput of my object: structure(list(date = structure(c(1568937600, 1569196800, 1569283200, 1569369600, 1569456000, 1569542400, 1569801600, 1569888000, 1569974400, 1570060800, 1570147200, 1570406400, 1570492800, 1570579200, 1570665600, 1570752000, 1571011200, 1571097600, 1571184000, 1571270400, 1571356800, 1571616000, 1571702400, 1571788800, […]

Categories
Mastering Development

Calculating rolling correlations on time series

I have a tbl-df object and I need to calculate 22 days rolling correlations between the values in second and third column. This is the dput of my object: structure(list(date = structure(c(1568937600, 1569196800, 1569283200, 1569369600, 1569456000, 1569542400, 1569801600, 1569888000, 1569974400, 1570060800, 1570147200, 1570406400, 1570492800, 1570579200, 1570665600, 1570752000, 1571011200, 1571097600, 1571184000, 1571270400, 1571356800, 1571616000, 1571702400, 1571788800, […]

Categories
Mastering Development

R grouping data by numeric numbers in a column

I am trying to group data by numbers in a column, I have tried different versions of group_by, cut, group etc but I have not been able to get it. I have a lot of data that looks like this: position variants 3 snv 5 snv 12 snv 17 mnv 22 deletion 27 snv 33 […]

Categories
Mastering Development

How to create a Infinite List in Haskell where the new value consumes all the previous values

If I create a infinite list like this: let t xs = xs ++ [sum(xs)] let xs = [1,2] : map (t) xs take 10 xs I will get this result: [ [1,2], [1,2,3], [1,2,3,6], [1,2,3,6,12], [1,2,3,6,12,24], [1,2,3,6,12,24,48], [1,2,3,6,12,24,48,96], [1,2,3,6,12,24,48,96,192], [1,2,3,6,12,24,48,96,192,384], [1,2,3,6,12,24,48,96,192,384,768] ] This is pretty close to what I am trying to do. This […]

Categories
Mastering Development

Making comparing 2 tables with go faster (Postgres/SQLAlchemy)

I wrote a code in python to manipulate a table I have in my database. I am doing so using SQL Alchemy. Basically I have table 1 that has 2 500 000 entries. I have another table 2 with 200 000 entries. Basically what I am trying to do, is compare my source ip and […]

Categories
Mastering Development

Adding elements to a list and filtering the next elements to be appended using the list [closed]

[x,y] represents the residue class of y modulo x. I begin with the function g(x,y) (defined below). I’m interested in finding, for some power of two, say x=pow(2,w), all odd integers y<x such that [x,y]>g(x,y). Without discerning I get: [4,1],[8,5],[16, 1],[16,3],[16, 5],[16, 13],[32, 1],[32, 3],[32, 5],[32, 11],[32, 13],[32, 17],[32, 19],[32, 21],[32, 23],[32, 25],[32, 29]… But […]

Categories
Mastering Development

Drop rows from Pandas DF that contain elements in a list

Suppose I have a DF: students = [ (‘jack’, 34, ‘Sydeny’ , ‘Australia’) , (‘Riti’, 30, ‘Delhi’ , ‘India’ ) , (‘Vikas’, 31, ‘Mumbai’ , ‘India’ ) , (‘Neelu’, 32, ‘Bangalore’ , ‘India’ ) , (‘John’, 16, ‘New York’ , ‘US’) , (‘Mike’, 17, ‘las vegas’ , ‘US’) ] dfObj = pd.DataFrame(students, columns = [‘Name’ […]