On financial independence

To achieve financial independence, a state in which one’s asset generates more interest than one’s expense, it is generally assumed that one has to save early and save big, due to the power of compounding. This depends on one critical assumption, that the rolling return over 30 years remains largely the same regardless of the entry point in a 30 year period. Although accurate prediction of future returns is difficult to perform, computer simulations could be more easily applied to past data to confirm the assumption.

Data TBD by Miaomiao. 

Personal Goals:

  • Control monthly expense under 5k.
  • Based on this expense and the 4% rule, 1.5 M is needed to achieve perpetual financial freedom.
  • Achieve financial independence by age 40.
  • Save 71k per year after year, plus 401(k).

Skills to be developed by MM:

  • Trading/investment skills
  • General machine learning

Skills to be developed by TT:

  • Deep learning
  • Computer vision
  • Skills that is not employer specific, such as software development skills, apps development, English skills, speech skills.
On financial independence

installation of tensorflow on windows or MacOS

Windows:

I had the following error when installing tensorflow on windows 7 (Python 3.5.2 :: Anaconda 4.1.1 (64-bit))

Cannot remove entries from nonexistent file d:\anaconda32\envs\tst\lib\site-pack
ages\easy-install.pth

This is a anaconda environment problem. I found the solution here:

pip install --ignore-installed --upgrade pip setuptools
pip install --upgrade tensorflow

Now add the python from anaconda package permanently to cygwin.

echo 'export PATH=/cygdrive/c/anaconda3:$PATH' >> .bashrc

MacOS

Install TensorFlow in virtualenv to avoid version contamination.

mkvirtualenv cv -p python3
workon cv
pip3 install --upgrade tensorflow # for Python 3.n

Validate the installation

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

Run a test model

git clone https://github.com/tensorflow/models.git
cd ~/TensorFlow/models/tutorials/image/imagenet
python classify_image.py --image_file ~/TensorFlow/daisy.jpeg

TBD

installation of tensorflow on windows or MacOS

Affine and Perspective Transformation

In affine transformation (link, link2), all parallel lines in the original image will still be parallel in the output image. To find the transformation matrix, we need 3 points from input image and their corresponding locations in output image. Then cv2.getAffineTransform will create a 2×3 matrix which is to be passed to cv2.warpAffine. Affine transform can perform rotation, translation, resizing,

pts1 = np.float32([[50,50],[200,50],[50,200]])
pts2 = np.float32([[10,100],[200,50],[100,250]])

M = cv2.getAffineTransform(pts1,pts2)
dst = cv2.warpAffine(img,M,(cols,rows))

For perspective transformation (see links above), you need a 3×3 transformation matrix. Straight lines will remain straight even after the transformation. To find this transformation matrix, you need 4 points on the input image and corresponding points on the output image. Among these 4 points, 3 of them should not be collinear. Then transformation matrix can be found by the function cv2.getPerspectiveTransform. Then apply cv2.warpPerspective with this 3×3 transformation matrix.

pts1 = np.float32([[56,65],[368,52],[28,387],[389,390]])
pts2 = np.float32([[0,0],[300,0],[0,300],[300,300]])

M = cv2.getPerspectiveTransform(pts1,pts2)
dst = cv2.warpPerspective(img,M,(300,300))

In summary,

  • Affine transformation preserves lines and parallelism.
  • Perspective transformation preserves lines. Affine transform is a special case of perspective transformation.
  • PS, affine transformation does not preserve angle. Conformal transformation preserves angle.

 

Affine and Perspective Transformation