我是二年级的大学生,现在正在学习数据科学中使用的python。我在数据科学实验室做了一个练习,我必须完成这个功能。代码如下:
import matplotlib.pyplot as plt
import numpy as np
# Independent variable
num_hours_studied = np.array([1, 3, 3, 4, 5, 6, 7, 7, 8, 8, 10])
# Dependent variable
exam_score = np.array([18, 26, 31, 40, 55, 62, 71, 70, 75, 85, 97])
# Evaluate hypothesis over a design matrix
theta = np.array([1,1]) # here is my answer
def h(X,theta):
y_predicted = np.dot(X, theta.T) # here is my answer
raise NotImplementedError()
return y_predicted
当我运行代码时,在raise NotImplementedError()处有一个错误,但是当我注释该行时,结果显示:
[10 30 30 40 50 60 70 80 100]
预期产出:[10,30,30,40,50,60,70,70,80,80,100]
我的代码怎么了?我的答案正确吗?如何在不向“raise NotImplementedError()”添加注释的情况下不出错? 谢谢你的回答
目前没有回答
相关问题 更多 >
编程相关推荐