Chapter1: ML with Python Flashcards
This is summary of ML with Python book chapter1
Start Notebook from Cmd?
start fresh terminal ,and type …jupyter notebook
Mutiple Assigment in Python ?
In an assignment statement, the right-hand side is always evaluated fully before doing the actual setting of variables. So,
x, y = y, x + y
is diff from
x = y
y = x + y
In python , while evaluating an assignment, the right-hand side is evaluated before the left-hand side.
Python comes in many flavors, and there are many ways to install it. However, we recommend to install a scientific-computing distribution, that comes readily with optimized versions of scientific modules. What are they ?
There are several fully-featured Scientific Python distributions: • Anaconda • EPD WinPython
What are NumPy and NumPy arrays?
NumPyprovides: • extension package to Python for multi-dimensional arrays
Why is numpy useful?
Why it is useful:Memory-efficient container that provides fast numerical operations.
• How to find Interactive help in Numpy?
p.array?
What is the recommended way to inport numpy?
import numpy as np
Example of creating array with numpy?
○ a = np.array([0, 1, 2, 3]) ○ a.ndim … gives dimension of a which is 1 ○ a.shape gives (4,1) ○ len(a) = 4 ○ 2-D array § b = np.array([[0, 1, 2], [3, 4, 5]]) § b.ndim= 4 b.shape (2,3)
Functions for creating arrays?
a = np.arange(10)……. # 0 .. n-1 (!) b = np.arange(1, 9, 2) … start, end (exclusive), step
c = np.linspace(0, 1, 6) # start, end, num-points d = np.linspace(0, 1, 5, endpoint=False)
Np.zeros() Np.ones() Np.linspace() Np.arrange() Np.eye() Np.diag() Np.random.rand(4) Np.random.randn(4)
if a is an object. how can we check its data type?
a.dtype
Numpy auto detect data type from input, yes or NO?
Numpy auto detect data type from input
how can you specify data type of numpy array
C= np.array([2,3,4], dtype=folat)
What is the default data type in numpy?
The default data type is float
How to start python in notebook or ipython?
Start by launching IPython:
$ ipython
Or the notebook:
$ ipython notebook
How to enable interactive plot in python?
%matpotlib on ipython or %matpotlib inline on notebook. With inline plot are display not in anothe window