Python Basic Data Structure
List Basic
x = [3,1,2]
print(x, x[2])
print(x[-1])
x[2] = 'foo'
x.append('bar')
print(x)
back = x.pop()
print(back,x)
[3, 1, 2] 2
2
[3, 1, 'foo', 'bar']
bar [3, 1, 'foo']
OpenCV cheat sheet
image I/O
cv2.imread()
Syntax: cv2.imread(path, flag)
Parameters:
- path
- flag: It specifies the way in which image should be read. It’s default value is cv2.IMREAD_COLOR
cv2.IMREAD_COLOR:It specifies to load a color image, default flag, alternatively, we can pass 1 for this flag.
cv2.IMREAD_GRAYSCALE: It specifies to load an image in grayscale mode. Alternatively pass value 0.
cv2.IMREAD_UNCHANGED: It specifies to load an image including alpha channel.
Return Value: returns an image
OOP Comparison between C++ and Python
- Inheritance
- Polymorphism
- Encapsulation
- Abstraction
class definition
C++
//class
class Points
{
public:
//constructor
Points(int x, int y){
this->_x = x;
this->_y = y;
}
//print function
void print() const{
std::cout<<this->_x<<" "<<this->_y<<std::endl;
}
//public data members
string alias = "position of point";
private:
//private data members
int _x;
int _y;
};
Machine Learning Optimizer in summary
Quick Sort
- Python
Convolutional Neural Network from Scratch, Keras&Tensorflow
image I/O
cv2.imread()
Syntax: cv2.imread(path, flag)
Parameters:
- path
- flag: It specifies the way in which image should be read. It’s default value is cv2.IMREAD_COLOR
cv2.IMREAD_COLOR:It specifies to load a color image, default flag, alternatively, we can pass 1 for this flag.
cv2.IMREAD_GRAYSCALE: It specifies to load an image in grayscale mode. Alternatively pass value 0.
cv2.IMREAD_UNCHANGED: It specifies to load an image including alpha channel.
Return Value: returns an image
image basic operation
rotate cv2.rotate()
Syntax: cv2.rotate(src, rotateCode)
Parameters:
-
src: t is the image whose color space is to be changed
-
rotateCode: It is an enum to specify how to rotate the array.
- cv2.ROTATE_()_CLOCKWISE
- cv2.ROTATE_()_COUNTERCLOCKWISE
- cv2.ROTATE_180
Return value: It returns an image
Python File System Module
Glob Module
import glob
import cv2
data = []
files = glob.glob("source/*.jpg")
for file in files:
image = cv2.imread(file)
img = cv2.resize(image, (400,600), interpolation = cv2.INTER_AREA)
data.append(img)
Decision Tree
example
| Color | Diameter | Label |
|---|---|---|
| Green | 3 | Apple |
| Yellow | 3 | Apple |
| Red | 1 | Grape |
| Red | 1 | Grape |
| Yellow | 3 | Lemon |
Difficulties: No visual way to seperate features since sample 2 and sample 5 share the same features while having different labels
Family of Decision Tree Learning Algorithms:
- ID3
- C4.5
- C5.0
- CART
SSH Keys
Problem
How to create multiple github accounts and git push or pull automatically?
Solution
generate different ssh key
ssh-keygen -t rsa -C "Hadley_hzy@hotmail.com"
ssh-keygen -t rsa -C "Hou.z@husky.neu.edu"
for example, 2 keys created:
~/.ssh/id_rsa_hadleyhzy
~/.ssh/id_rsa_hadleyhzy34