least square method is a basic method to find a fitting line of a linear-like data. for more info check: http://www.wiki-zero.co/index.php?q=aHR0cHM6Ly9lbi53aWtpcGVkaWEub3JnL3dpa2kvTGVhc3Rfc3F1YXJlcw a good start for understanding regression in the machine learning. Also check this website for more clear understanding: http://www1.gantep.edu.tr/~bingul/ep208/docs/ep208-topic7.pdf The aim of this work is to show how easy python for statistics. You can try your own data but if it is not linear it can't give you the line you wish