Logistic function misclassification

I'm having trouble trying to teach a neural network the XOR logic function. I've already trained the network with succesful results using the hyperbolic tangent and ReLU as activation functions (regarding the ReLU, I know it's not the appropiate for ...
more »

2017-01-11 20:01 (0) Answers

How to custom sort pandas multi-index?

The following code generates the pandas table named out. import pandas as pd import numpy as np df = pd.DataFrame({'Book': ['B1', 'B1', 'B2', 'B3', 'B3', 'B3'], 'Trader': ['T1', 'Z2', 'Z2', 'T1', 'U3', 'T2'], ...
more »

2017-01-11 20:01 (2) Answers

Define trend pandas/python

I have dataset: print (df['price']) 0 0.435 1 -2.325 2 -3.866 ... 58 -35.876 59 -37.746 Name: price, dtype: float64 moving average: m_a = df['price'].rolling(window=5).mean() m_a.plot() print(m_a) 0 NaN 1 NaN 2 ...
more »

2017-01-11 20:01 (2) Answers

Pandas - Compare positive/negative values

I have a dataframe "df": x y 0 1 -1 1 -2 -3 2 3 4 3 4 5 4 9 6 I am trying to determine what percentage of x and y values are in agreement in terms of being positive or negative. So if x is positive and y is positive, that wou...
more »

2017-01-11 18:01 (1) Answers

Covariance between a 1-d and a 3-d array in Python

I have a dataset created through xarray with its assigned coordinates and dimensions. Obtained from that, I also have two variables: a 1-dimensional array and a 3-dimensional one, with the same coordinate as the first one and two additional ones. I w...
more »

2017-01-11 16:01 (1) Answers

Pandas: How to make apply on dataframe faster?

Consider this pandas example where I'm calculating column C by multiplying A with B and a float if a certain condition is fulfilled using apply with a lambda function: import pandas as pd df = pd.DataFrame({'A':[1,2,3,4,5,6,7,8,9],'B':[9,8,7,6,5,4,3...
more »

2017-01-11 11:01 (4) Answers

Extract patches from 3D Matrix

I have a 3D matrix A of dimensions h x w x c. I want to extract patches of dimensions ph x pw from each "channel" c. ph divides h and pw divides w. In this example, h x w x c = 4 x 4 x 3 ph x pw = 2 x 2 I know how to do this in tensorflow using ...
more »

2017-01-11 09:01 (1) Answers

Issue with joining repeated values/rows

New to python, cant seem to understand how to proceed. After using bin and editing my data frame i was able to come up with this : Continents % Renewable Country 0 Asia (15.753, 29.227] China 1 North America (2.212, 15.753] United S...
more »

2017-01-11 08:01 (2) Answers

Multiple matrix multiplication

In numpy, I have an array of N 3x3 matrices. This would be an example of how I'm storing them (I'm abstracting away the contents): N = 10 matrices = np.ones((N, 3, 3)) I also have an array of 3-vectors, this would be an example: vectors = np.ones...
more »

2017-01-10 23:01 (1) Answers

Listen for incoming emails in python

I'm using the python imap and email libraries to automate an email process I'm working on and I need to find a way to call a function when an email is received automatically. So far I've looked into using the sched library to check at regularly sched...
more »

2017-01-10 21:01 (0) Answers