Python3 Installing the NumPy Science Library

Source: Internet
Author: User

[[email protected] numpy]# wget https://pypi.python.org/packages/ee/66/7c2690141c520db08b6a6f852fa768f421b0b50683b7bbcd88ef51f33170/numpy-1.14.0.zip[[email protected] numpy]# md5sum numpy-1.14.0.zip c12d4bf380ac925fcdc8a59ada6c3298 numpy-1.14.0.zip[[email protected] numpy]# unzip numpy-1.14.0.zip [[email protected] numpy]# cd numpy-1.14.0[[email protected] numpy-1.14.0]# cat INSTALL.rst.txt #安装说明[[email protected] numpy-1.14.0]# python3 setup.py build install --prefix /root/python/numpy #注意安装路径[[email protected] numpy-1.14.0]# echo "export PYTHONPATH=/root/python/numpy/lib/python3.6/site-packages" >> ~/.bashrc #注意安装路径[[email protected] numpy-1.14.0]# . ~/.bashrc[[email protected] numpy-1.14.0]# echo $?0[[email protected] numpy-1.14.0]#

Write a linear regression test

[[email protected] work.dir]# cat SimpleLineRegression.py #!/usr/bin/python3import numpy as npdef fitSLR(x,y):    n = len(x)    dinominator = 0    numerator = 0    for i in range(0, n):        numerator += (x[i] - np.mean(x)) * (y[i] - np.mean(y))        dinominator +=(x[i] - np.mean(x)) ** 2    print ("numerator:", numerator)    print ("dinominator", dinominator)    b1 = numerator/float(dinominator)    b0 = np.mean(y)/float(np.mean(x))    return b0, b1def predict(x, b0, b1):    return b0 + x*b1x = [1,3,2,1,3]y = [14,24,18,17,27]b0, b1 = fitSLR(x,y)print ("intercept:", b0, " slope:", b1)x_test = 6y_test = predict(6, b0, b1)print("y_test", y_test)[[email protected] work.dir]# ./SimpleLineRegression.py numerator: 20.0dinominator 4.0intercept: 10.0  

Python3 Installing the NumPy Science Library

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.