menu
Create a (Python) Script with a Head Including Information

date_range Mar. 13, 2019 - Wednesday

Problem:

Every time when you create a new script, you alway need to add some information about the script, like create time, author, description, etc. But if you type in by hand every time, it’s time consuming, and also it’s hard to make a uniformed format.

Solution:

  • Write a simple Bash script to auto-generate a new (Python) script is good way to solve the problem above.

The script - kftouchpy:

FILE=$1
echo "\"\"\"
Filename: $FILE
Created on `date`

@author: Kefeng Zhu (john@doe.com)
Description:

\"\"\"
" > $FILE

Usage:

Simply run sh kftouchpy newfile.py, then open the newly created file newfile.py, we have:

"""
Filename: newfile.py
Created on Wed Mar 13 10:37:16 CST 2019

@author: Kefeng Zhu (john@doe.com)

Description:

"""

Make it More Convenient:

Puth the bash script in a directory that is included in your $PATH, and also remember to make it execuable. In this way, you can directly type kftouchpy newfile. Jobs Done!



KF

Python Modules and Packages

date_range Mar. 07, 2019 - Thursday

Programming in python with modules and packages is always good practice.

There are several advantages to modularizing code in a large application:

  • Simplicity: Rather than focusing on the entire problem at hand, a module typically focuses on one relatively small portion of the problem. If you’re working on a single module, you’ll have a smaller problem domain to wrap your head around. This makes development easier and less error-prone.
  • Maintainability: Modules are typically designed so that they enforce logical boundaries between different problem domains. If modules are written in a way that minimizes interdependency, there is decreased likelihood that modifications to a single module will have an impact on other parts of the program. (You may even be able to make changes to a module without having any knowledge of the application outside that module.) This makes it more viable for a team of many programmers to work collaboratively on a large application.
  • Reusability: Functionality defined in a single module can be easily reused (through an appropriately defined interface) by other parts of the application. This eliminates the need to recreate duplicate code.
  • Scoping: Modules typically define a separate namespace, which helps avoid collisions between identifiers in different areas of a program. (One of the tenets in the Zen of Python is Namespaces are one honking great idea—let’s do more of those!)

Here is a collection of Python modules and packages.

[CS229] Lecture 6 Notes - Support Vector Machines I

date_range Mar. 05, 2019 - Tuesday

  • Introduce Support Vector Machines (SVM)
  • Created on 02/27/2019
  • Updated on 03/04/2019
  • Updated on 03/05/2019

What is DOM?

date_range Feb. 28, 2019 - Thursday

It’s the abbre. of Document Object Model (DOM)

In short:

The Document Object Model (DOM) is an application programming interface (API) for valid HTML and well-formed XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated. In the DOM specification, the term “document” is used in the broad sense - increasingly, XML is being used as a way of representing many different kinds of information that may be stored in diverse systems, and much of this would traditionally be seen as data rather than as documents. Nevertheless, XML presents this data as documents, and the DOM may be used to manage this data.

Reference

What is the Document Object Model? - w3.org

KF

[Python/NumPy] Matrix(Arrays) Manipulations & Operations

date_range Feb. 28, 2019 - Thursday

A collection of frequently used python/numpy techniques on matrix (numpy arrays) manipulation and operations.

[CS231] K-Nearest-Neighbor Classifier

date_range Feb. 28, 2019 - Thursday

gist of KNN Classifier.

[CS229] Lecture 5 Notes - Descriminative Learning v.s. Generative Learning Algorithm

date_range Feb. 18, 2019 - Monday

Keep Updating:

  • 2019-02-18 Merge to Lecture #5 Note
  • 2019-01-23 Add Part 2, Gausian discriminant analysis
  • 2019-01-22 Add Part 1, A Review of Generative Learning Algorithms.