-
大小: 2KB文件類型: .zip金幣: 1下載: 0 次發(fā)布日期: 2021-01-04
- 語言: 其他
- 標(biāo)簽: planar_utils??
資源簡介
吳恩達深度學(xué)習(xí)作業(yè)用到的planar_utils.py和testCases_cv2.py
代碼片段和文件信息
import?matplotlib.pyplot?as?plt
import?numpy?as?np
import?sklearn
import?sklearn.datasets
import?sklearn.linear_model
def?plot_decision_boundary(model?X?y):
????#?Set?min?and?max?values?and?give?it?some?padding
????x_min?x_max?=?X[0?:].min()?-?1?X[0?:].max()?+?1
????y_min?y_max?=?X[1?:].min()?-?1?X[1?:].max()?+?1
????h?=?0.01
????#?Generate?a?grid?of?points?with?distance?h?between?them
????xx?yy?=?np.meshgrid(np.arange(x_min?x_max?h)?np.arange(y_min?y_max?h))
????#?Predict?the?function?value?for?the?whole?grid
????Z?=?model(np.c_[xx.ravel()?yy.ravel()])
????Z?=?Z.reshape(xx.shape)
????#?Plot?the?contour?and?training?examples
????plt.contourf(xx?yy?Z?cmap=plt.cm.Spectral)
????plt.ylabel(‘x2‘)
????plt.xlabel(‘x1‘)
????plt.scatter(X[0?:]?X[1?:]?c=y.reshape(y.shape[1])
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????2273??2018-04-14?13:32??數(shù)據(jù)集\planar_utils.py
?????文件????????3996??2018-04-14?13:34??數(shù)據(jù)集\testCases_v2.py
?????目錄???????????0??2018-04-14?13:37??數(shù)據(jù)集\
評論
共有 條評論