Comments (10)
I used
plt.savefig("attribute_histogram_plots")
instead of
save_fig("attribute_histogram_plots")
then it works!
from handson-ml.
Hi @loewenm,
Thanks for your kind words, I'm glad you are enjoying my book. :)
The save_fig()
function is defined in the first cell of each notebook: just run that cell and the error should go away. You would typically get the NameError: name 'save_fig' is not defined
error if you restart Jupyter (or just the Python kernel) and then go back to the cell you were at without running the previous cells again. When you want to continue running a notebook after an interruption, you need to run the previous cells again, because the Python kernel has lost all the context.
I hope this helps. Can you please point me to the discussion threads about this, so I can help them out? Thanks!
Cheers,
Aurélien
from handson-ml.
from handson-ml.
Hi @loewenm ,
Sorry for the delay, I missed your message as the issue was closed. Did you manage to get the code to run in Spyder? The piece of code you asked me to run does not include the definition of the save_fig()
function, so it's normal to get an error saying that the function is undefined. You need to make sure you have the following function definition at the beginning of your code:
# Imports
import os
import matplotlib.pyplot as plt
# Where to save the figures
PROJECT_ROOT_DIR = "."
CHAPTER_ID = "fundamentals"
def save_fig(fig_id, tight_layout=True):
path = os.path.join(PROJECT_ROOT_DIR, "images", CHAPTER_ID, fig_id + ".png")
print("Saving figure", fig_id)
if tight_layout:
plt.tight_layout()
plt.savefig(path, format='png', dpi=300)
from handson-ml.
I'm glad this helped! Regarding QML, it's definitely fascinating, but I'm afraid I really don't know much about this topic (yet?). I read an introductory book about Quantum Physics about 10 years ago, and it blew my mind. I was so motivated to learn that I bought an actual university textbook, but I was lost after reading only about 10 pages. I should try again, perhaps it would be easier now that I've practiced a lot of Linear Algebra.
I'd love to read your thoughts about the topic: what do you think will be the main applications? Is it mostly about faster training time? Exploring huge hyperparameter spaces? Training on quantum data?
from handson-ml.
Thanks, UlrikeBoehm. It does!
from handson-ml.
Thanks! save_fig my ...
from handson-ml.
I used
plt.savefig("attribute_histogram_plots")
instead of
save_fig("attribute_histogram_plots")
then it works!
That was really very help full, it's working rather then what's described above
from handson-ml.
Hi @Neeraj02a ,
Thanks for your feedback. My save_fig()
function is just a thin wrapper for Matplotlib's plt.savefig()
function. It just handles the file path (so that each image is saved into the appropriate folder, for example in images/fundamentals if you're running the chapter 1 notebook), and by default it also calls plt.tight_layout()
to save some space. Lastly, it ensures the output format is PNG and the resolution is 300 dpi. This is the format expected by O'Reilly: they need print-quality images.
If you get an error when calling save_fig()
, it might be because you're missing some of the imports? I added the ones you need in the code example above.
Hope this helps.
from handson-ml.
Thank you @ageron for such a well explained resolution. I had the same issue but coming here gave me the best insights.
from handson-ml.
Related Issues (20)
- mnist dataset HOT 2
- Chapter#02 FileNotFoundError HOT 1
- Chapter 2 error during prediction HOT 2
- Ml
- Dropout at test time HOT 3
- How can I use my own dataset and fit it to your code
- Need help understanding crc hash used to explain test train split in Chapter 2 HOT 1
- ImportError: cannot import name 'fetch_mldata' from 'sklearn.datasets' (F:\Anaconda3\lib\site-packages\sklearn\datasets\__init__.py) HOT 1
- Chapter 3 : Exercise 1 - MNIST Classifier with 97% accuracy - Could not pickle the task to send it to the workers. HOT 3
- Broken image in readme HOT 1
- Chapter 5 SVM why should center before LinearSVC
- Chapter 3 (Page 82): Getting error during Fitting the SGD Classifier with Training data
- Chapter 2: Value differences in prediction
- Chapter 2: Looking for Correlations - ValueError: could not convert string to float: 'INLAND' HOT 1
- Use github.com/apssouza22/chatflow as a conversational layer. It would enable actual API requests to be carried out from natural language inputs.
- chapter 4: SGDRegressor(tol=-np.infty) is not accepted by the module HOT 1
- Hi
- Ch.2 Error using corr() HOT 1
- Problem downloading data HOT 1
- Why does saving the test set not work?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from handson-ml.