Python3 설치numpy 과학 라이브러리 단순 선형 회귀
[root@Singapore numpy]# wget https://pypi.python.org/packages/ee/66/7c2690141c520db08b6a6f852fa768f421b0b50683b7bbcd88ef51f33170/numpy-1.14.0.zip
[root@Singapore numpy]# md5sum numpy-1.14.0.zip
c12d4bf380ac925fcdc8a59ada6c3298 numpy-1.14.0.zip
[root@Singapore numpy]# unzip numpy-1.14.0.zip
[root@Singapore numpy]# cd numpy-1.14.0
[root@Singapore numpy-1.14.0]# cat INSTALL.rst.txt #
[root@Singapore numpy-1.14.0]# python3 setup.py build install --prefix /root/python/numpy #
[root@Singapore numpy-1.14.0]# echo "export PYTHONPATH=/root/python/numpy/lib/python3.6/site-packages" >> ~/.bashrc #
[root@Singapore numpy-1.14.0]# . ~/.bashrc
[root@Singapore numpy-1.14.0]# echo $?
0
[root@Singapore numpy-1.14.0]#
선형 컴백을 한번 써볼게요.
[root@Singapore work.dir]# cat SimpleLineRegression.py
#!/usr/bin/python3
import numpy as np
def 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, b1
def predict(x, b0, b1):
return b0 + x*b1
x = [1,3,2,1,3]
y = [14,24,18,17,27]
b0, b1 = fitSLR(x,y)
print ("intercept:", b0, " slope:", b1)
x_test = 6
y_test = predict(6, b0, b1)
print("y_test", y_test)
[root@Singapore work.dir]# ./SimpleLineRegression.py
numerator: 20.0
dinominator 4.0
intercept: 10.0 slope: 5.0
y_test 40.0
[root@Singapore work.dir]#
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
#2_Raspberry Pi 3B+에서 LINE에 일기 예보 알림도쿄에 와서 갑자기 비가 오는 경우가 많습니다. "아침 제대로 일기 예보를 체크해 두면..."라고 후회하는 것이 자주. LINE에 매일 아침 일기 예보를 보내 주시면 좋지 않아? 라고 생각하고 만들어 보기로 했습니다...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.