Chapter1: ML with Python Flashcards
This is summary of ML with Python book chapter1 (38 cards)
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
What is Matplotlib?
is a 2D plotting package
How to import matplotlib?
import matplotlib.pyplot as plt….The tidy way
What is Machine Learning about?
Machine learning is about extracting knowledge from data
What is intersection of ML and its another names?
• It is a research field at the intersection of statistics, artificial intelligence, and computer science and is also known as predictive analytics or statistical learning
Why Machine Learning?
In the early days of “intelligent” applications, many systems used handcoded rules of “if” and “else” decisions to process data or adjust to user input.
What is two major Disadvantage of handcoded rule use before?
The logic required to make a decision is specific to a single domain and task. Changing the task even slightly might require a rewrite of the whole system
• Designing rules requires a deep understanding of how a decision should be made
by a human expert.
Problems Machine Learning Can Solve
○ The most successful kinds of machine learning algorithms are those that automated decision-making processes by generalizing from known examples. In this setting, which is known as supervised learning, the user provides the algorithm with pairs of inputs and desired outputs, and the algorithm finds a way to produce the desired out‐ put given an input
○ Machine learning algorithms that learn from input/output pairs are called supervised learning algorithms because a “teacher” provides supervision to the algorithms in the form of the desired outputs for each example that they learn from. While creating a dataset of inputs and outputs is often a laborious manual process, supervised learning algorithms are well understood and their performance is easy to measure
○ If your application can be formulated as a supervised learning problem, and you are able to create a dataset that includes the desired outcome, machine learning will likely be able to solve your problem.
While you are building a machine learning solution , you should answer, or at least keep in mind, the following questions:?
What question(s) am I trying to answer? Do I think the data collected can answer that question?
• What is the best way to phrase my question(s) as a machine learning problem?
• Have I collected enough data to represent the problem I want to solve?
• What features of the data did I extract, and will these enable the right predictions?
• How will I measure success in my application?
• How will the machine learning solution interact with other parts of my research or business product?
Knowing Your Task and Knowing Your Data
It will not be effective to randomly choose an algorithm and throw your data a it. It is necessary to understand what is going on in your dataset before you begin building a model Each algorithm is different in ter terms of what kind of data and what problem setting it works best for