top of page
Writer's pictureHui Wang

87. Machine learning: Use of Jupyter Notebook

Jupyter Notebooks are a web-based interactive computing platform that allows users to combine code, text, and other media in a single document. They are often used for data visualization, data cleaning and transformation, and machine learning.


Anaconda includes the Jupyter Notebook as part of its distribution, so you can use it to run and interact with your Python code within Anaconda.


To start a new Jupyter Notebook, you can use the Anaconda Navigator, which is a graphical user interface included with Anaconda that makes it easy to launch applications and manage packages.


Alternatively, you can use the command-line interface to start a Jupyter Notebook by running the following command:

jupyter notebook

This will launch a new web browser window with the Jupyter Notebook interface, where you can create and run new notebooks or open existing ones.


In a Jupyter Notebook, you can write and execute Python code, as well as include text, images, and other media in cells that can be formatted using Markdown. You can also visualize data and create plots using libraries like Matplotlib and Seaborn. Jupyter Notebooks are a popular tool for data science and machine learning workflows because they allow you to easily document and reproduce your work.


For example:


Here are some of the most commonly used shortcut keys in Jupyter Notebooks:

  • Shift + Enter: Run the current cell and move to the next cell

  • Ctrl + Enter: Run the current cell

  • Esc + A: Insert a new cell above the current cell

  • Esc + B: Insert a new cell below the current cell

  • Esc + D + D: Delete the current cell

  • Esc + M: Convert the current cell to Markdown

  • Esc + Y: Convert the current cell to code

  • Esc + L: Toggle line numbers in the current cell

  • Esc + O: Toggle the output of the current cell

  • Esc + Shift + F: Find and replace in the notebook

  • Esc + Shift + L: Toggle line numbers for all cells

  • Esc + Shift + M: Merge the selected cells

Note that you will need to press the Esc key first to enter command mode, and then you can use these shortcut keys. You can also find a list of all available shortcut keys by going to the Help menu in the Jupyter Notebook interface and selecting the "Keyboard Shortcuts" option.


%lsmagic

%lsmagic is a Jupyter Notebook magic command that displays a list of all available magic commands. Magic commands are special commands that are not part of the Python language, but provide additional functionality within the Jupyter Notebook. They are prefixed with a percentage sign (%) for single-line magic commands, and a double percentage sign (%%) for multi-line magic commands.


To use the %lsmagic command, simply type %lsmagic in a cell and run it. This will display a list of all available magic commands, as well as a brief description of each one.


Here is an example of using %lsmagic in a Jupyter Notebook:


Recent Posts

See All

Comments


bottom of page