0
我正試圖在python中導入統計數據模塊。當我執行程序時,它給我一個錯誤消息。無法從統計數據中導入平均值
這裏是我的代碼:
from statistics import mean
import numpy as np
import matplotlib.pyplot as plt
xs = np.array([1,2,3,4,5,6,7,8])
ys = np.array([2,8,5,0,5,7,3,6])
def best_fit_line(xs ,ys):
m = (((mean(xs)* mean(ys))- mean(xs*ys))/
(mean(xs)*mean(xs))-(mean(xs*xs)))
return m
m = best_fit_line(xs,ys)
錯誤消息:
Traceback (most recent call last):
File "/home/kudzai/Documents/Machine Learning/LinearRegAlg.py", line 1, in <module>
from statistics import mean
ImportError: No module named statistics