packtpublishing / machine-learning-for-finance Goto Github PK
View Code? Open in Web Editor NEWMachine Learning for Finance, published by Packt
License: MIT License
Machine Learning for Finance, published by Packt
License: MIT License
Hi,
And even with the help of SOF I still cannot reproduce the numbers you've got in your git. I'm getting the following:
Epoch 1/5
13013/13013 [==============================] - 17s 1ms/step - loss: 825128.0000 - acc: 0.8998 - val_loss: 211068.5156 - val_acc: 0.9019
Epoch 2/5
13013/13013 [==============================] - 16s 1ms/step - loss: 766153.7500 - acc: 0.9068 - val_loss: 582742.2500 - val_acc: 0.8027
ImportError Traceback (most recent call last)
in ()
1 from keras.models import Sequential
2 from keras.layers import Dense, Activation
----> 3 from keras.optimizers import SGD
ImportError: cannot import name 'SGD' from 'keras.optimizers' (/usr/local/lib/python3.7/dist-packages/keras/optimizers.py)
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
Hi,
At page 54 of this book, there is a formula for counting origin accounts have insufficient funds. As the code below:
len(dfOdd[(dfOdd.oldBalanceOrig <= dfOdd.amount)]) / len(dfOdd)
This formula get 0.89664... , close to 90% of the odd transactions have insufficient funds.
Since we want accounts of insufficient funds before transaction. why use " <= " not. " < " ?
( The latter one get 0.21762... )
Regards,
Steven
@JannesKlaas
Hi Jannes,
Thank you for the amazing book and the tutorials, I really appreciate the time and effort you have put into the book.
I am wondering if there is somewhere that you have posted the answers of the exercieses for us to double check?
Since this is completely self-study, having answers to look up would be helpful to let me know that I am at least in the right direction.
Thanks.
@JannesKlaas
Hi Jannes,
In chapater 1,
...
A deeper network
...
def plot_decision_boundary(pred_func):
# Set min and max values and give it some padding
x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5
h = 0.01
# Generate a grid of points with distance h between them
xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))
# Predict the function value for the whole gid
Z = pred_func(np.c_[xx.ravel(), yy.ravel()])
Z = Z.reshape(xx.shape)
# Plot the contour and training examples
plt.contourf(xx, yy, Z, cmap=plt.cm.Spectral)
plt.scatter(X[:, 0], X[:, 1], c=y.flatten(), cmap=plt.cm.Spectral)
NameError Traceback (most recent call last)
/tmp/ipykernel_27/694468409.py in
15
16 #Plot the decision boundary
---> 17 plot_decision_boundary(lambda x: predict(model, x))
18 plt.title("Decision Boundary for hidden layer size 3")
19
/tmp/ipykernel_27/2764471563.py in plot_decision_boundary(pre_func)
114 xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))
115 #Predict the function value for the whole gid
--> 116 Z = pred_func(np.c_[xx_ravel(), yy_ravel()])
117 Z = Z.reshape(xx.shape)
118 #Plot the contour and training examples
NameError: name 'pred_func' is not defined
I keep getting this error, trying to solve it but havent be able to, I am using python 3.0 from mini-conda, thanks.
epoch = 5000 # Number of games played in training, I found the model needs about 4,000 games till it plays well
# Train the model
# For simplicity of the noteb
hist = train(model, epoch, verbose=1)
print("Training done")
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-11-1e110d42c25b> in <module>
3 # Train the model
4 # For simplicity of the noteb
----> 5 hist = train(model, epoch, verbose=1)
6
7 print("Training done")
<ipython-input-10-b5900a520e40> in train(model, epochs, verbose)
12 game_over = False
13 # get initial input
---> 14 input_t = env.observe()
15
16 while not game_over:
<ipython-input-2-a9f37a9957fc> in observe(self)
57
58 def observe(self):
---> 59 canvas = self._draw_state()
60 return canvas.reshape((1, -1))
61
<ipython-input-2-a9f37a9957fc> in _draw_state(self)
36 canvas[state[0], state[1]] = 1 # draw fruit
37
---> 38 canvas[-1, state[2] -1:state[2] + 2] = 1 # draw basket
39
40 return canvas
TypeError: only integer scalar arrays can be converted to a scalar index
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.