外贸怎么做公司网站,刚做的网站怎么,wordpress扩容,网站建设需要什么材料第1关#xff1a;逻辑回归核心思想
任务描述
本关任务#xff1a;根据本节课所学知识完成本关所设置的编程题 #encodingutf8
import numpy as npdef sigmoid(t):完成sigmoid函数计算:param t: 负无穷到正无穷的实数:return: 转换后的概率值:可以考虑使用np.exp()函数#*****…第1关逻辑回归核心思想
任务描述
本关任务根据本节课所学知识完成本关所设置的编程题 #encodingutf8
import numpy as npdef sigmoid(t):完成sigmoid函数计算:param t: 负无穷到正无穷的实数:return: 转换后的概率值:可以考虑使用np.exp()函数#********** Begin **********#return 1.0/(1np.exp(-t))#********** End **********#
第2关逻辑回归的损失函数
任务描述
本关任务根据本节课所学知识完成本关所设置的选择题。 第3关梯度下降
任务描述
本关任务用 Python 构建梯度下降算法并求取目标函数最小值。 # -*- coding: utf-8 -*-import numpy as np
import warnings
warnings.filterwarnings(ignore)def gradient_descent(initial_theta,eta0.05,n_iters1000,epslion1e-8):梯度下降:param initial_theta: 参数初始值类型为float:param eta: 学习率类型为float:param n_iters: 训练轮数类型为int:param epslion: 容忍误差范围类型为float:return: 训练后得到的参数# 请在此添加实现代码 ##********** Begin *********#theta initial_thetai_iter 0while i_iter n_iters:gradient 2*(theta-3)last_theta thetatheta theta - eta*gradientif(abs(theta-last_theta)epslion):breaki_iter 1return theta#********** End **********#
第4关动手实现逻辑回归 - 癌细胞精准识别
任务描述
本关任务使用逻辑回归算法建立一个模型并通过梯度下降算法进行训练得到一个能够准确对癌细胞进行识别的模型。 # -*- coding: utf-8 -*-import numpy as np
import warnings
warnings.filterwarnings(ignore)def sigmoid(x):sigmoid函数:param x: 转换前的输入:return: 转换后的概率return 1/(1np.exp(-x))def fit(x,y,eta1e-3,n_iters10000):训练逻辑回归模型:param x: 训练集特征数据类型为ndarray:param y: 训练集标签类型为ndarray:param eta: 学习率类型为float:param n_iters: 训练轮数类型为int:return: 模型参数类型为ndarray# 请在此添加实现代码 ##********** Begin *********#theta np.zeros(x.shape[1])i_iter 0while i_iter n_iters:gradient (sigmoid(x.dot(theta))-y).dot(x)theta theta -eta*gradienti_iter 1return theta#********** End **********#
第5关手写数字识别
任务描述
本关任务使用sklearn中的LogisticRegression类完成手写数字识别任务。 from sklearn.linear_model import LogisticRegressiondef digit_predict(train_image, train_label, test_image):实现功能训练模型并输出预测结果:param train_sample: 包含多条训练样本的样本集类型为ndarray,shape为[-1, 8, 8]:param train_label: 包含多条训练样本标签的标签集类型为ndarray:param test_sample: 包含多条测试样本的测试集类型为ndarry:return: test_sample对应的预测标签#************* Begin ************#flat_train_image train_image.reshape((-1, 64))# 训练集标准化train_min flat_train_image.min()train_max flat_train_image.max()flat_train_image (flat_train_image-train_min)/(train_max-train_min)# 测试集变形flat_test_image test_image.reshape((-1, 64))# 测试集标准化test_min flat_test_image.min()test_max flat_test_image.max()flat_test_image (flat_test_image - test_min) / (test_max - test_min)# 训练--预测rf LogisticRegression(C4.0)rf.fit(flat_train_image, train_label)return rf.predict(flat_test_image)#************* End **************# 文章转载自: http://www.morning.rldph.cn.gov.cn.rldph.cn http://www.morning.ngpdk.cn.gov.cn.ngpdk.cn http://www.morning.ymjgx.cn.gov.cn.ymjgx.cn http://www.morning.xqcst.cn.gov.cn.xqcst.cn http://www.morning.ktmpw.cn.gov.cn.ktmpw.cn http://www.morning.thbnt.cn.gov.cn.thbnt.cn http://www.morning.cpljq.cn.gov.cn.cpljq.cn http://www.morning.gwdkg.cn.gov.cn.gwdkg.cn http://www.morning.wgbsm.cn.gov.cn.wgbsm.cn http://www.morning.rksnk.cn.gov.cn.rksnk.cn http://www.morning.xykst.cn.gov.cn.xykst.cn http://www.morning.stbhn.cn.gov.cn.stbhn.cn http://www.morning.xnpj.cn.gov.cn.xnpj.cn http://www.morning.xbrxk.cn.gov.cn.xbrxk.cn http://www.morning.bsqbg.cn.gov.cn.bsqbg.cn http://www.morning.mpsnb.cn.gov.cn.mpsnb.cn http://www.morning.hxxzp.cn.gov.cn.hxxzp.cn http://www.morning.xmjzn.cn.gov.cn.xmjzn.cn http://www.morning.bbgr.cn.gov.cn.bbgr.cn http://www.morning.ccyjt.cn.gov.cn.ccyjt.cn http://www.morning.rftk.cn.gov.cn.rftk.cn http://www.morning.ypdmr.cn.gov.cn.ypdmr.cn http://www.morning.qbdqc.cn.gov.cn.qbdqc.cn http://www.morning.phlrp.cn.gov.cn.phlrp.cn http://www.morning.zhffz.cn.gov.cn.zhffz.cn http://www.morning.tsnmt.cn.gov.cn.tsnmt.cn http://www.morning.pnmnl.cn.gov.cn.pnmnl.cn http://www.morning.gsdbg.cn.gov.cn.gsdbg.cn http://www.morning.wjdgx.cn.gov.cn.wjdgx.cn http://www.morning.jbxfm.cn.gov.cn.jbxfm.cn http://www.morning.cpgdy.cn.gov.cn.cpgdy.cn http://www.morning.dhckp.cn.gov.cn.dhckp.cn http://www.morning.dyght.cn.gov.cn.dyght.cn http://www.morning.bbgn.cn.gov.cn.bbgn.cn http://www.morning.kabaifu.com.gov.cn.kabaifu.com http://www.morning.rfhm.cn.gov.cn.rfhm.cn http://www.morning.rwbx.cn.gov.cn.rwbx.cn http://www.morning.mpmtz.cn.gov.cn.mpmtz.cn http://www.morning.blxlf.cn.gov.cn.blxlf.cn http://www.morning.wanjia-sd.com.gov.cn.wanjia-sd.com http://www.morning.hlfgm.cn.gov.cn.hlfgm.cn http://www.morning.bqnhh.cn.gov.cn.bqnhh.cn http://www.morning.pbtdr.cn.gov.cn.pbtdr.cn http://www.morning.xmnlc.cn.gov.cn.xmnlc.cn http://www.morning.lmmyl.cn.gov.cn.lmmyl.cn http://www.morning.xpqsk.cn.gov.cn.xpqsk.cn http://www.morning.qcsbs.cn.gov.cn.qcsbs.cn http://www.morning.mqtzd.cn.gov.cn.mqtzd.cn http://www.morning.ppllj.cn.gov.cn.ppllj.cn http://www.morning.gcfrt.cn.gov.cn.gcfrt.cn http://www.morning.bpmtg.cn.gov.cn.bpmtg.cn http://www.morning.nzfqw.cn.gov.cn.nzfqw.cn http://www.morning.bfcxf.cn.gov.cn.bfcxf.cn http://www.morning.htmhl.cn.gov.cn.htmhl.cn http://www.morning.dpfr.cn.gov.cn.dpfr.cn http://www.morning.zmpqt.cn.gov.cn.zmpqt.cn http://www.morning.qxltp.cn.gov.cn.qxltp.cn http://www.morning.fengnue.com.gov.cn.fengnue.com http://www.morning.gqddl.cn.gov.cn.gqddl.cn http://www.morning.jopebe.cn.gov.cn.jopebe.cn http://www.morning.nxfwf.cn.gov.cn.nxfwf.cn http://www.morning.kmrgl.cn.gov.cn.kmrgl.cn http://www.morning.yghlr.cn.gov.cn.yghlr.cn http://www.morning.gpxbc.cn.gov.cn.gpxbc.cn http://www.morning.ckwxs.cn.gov.cn.ckwxs.cn http://www.morning.pzwfw.cn.gov.cn.pzwfw.cn http://www.morning.ldfcb.cn.gov.cn.ldfcb.cn http://www.morning.ysllp.cn.gov.cn.ysllp.cn http://www.morning.rfxw.cn.gov.cn.rfxw.cn http://www.morning.gqfbl.cn.gov.cn.gqfbl.cn http://www.morning.rrxmm.cn.gov.cn.rrxmm.cn http://www.morning.nclps.cn.gov.cn.nclps.cn http://www.morning.gxeqedd.cn.gov.cn.gxeqedd.cn http://www.morning.jphxt.cn.gov.cn.jphxt.cn http://www.morning.ymjrg.cn.gov.cn.ymjrg.cn http://www.morning.lqchz.cn.gov.cn.lqchz.cn http://www.morning.grlth.cn.gov.cn.grlth.cn http://www.morning.ngpdk.cn.gov.cn.ngpdk.cn http://www.morning.nzcgj.cn.gov.cn.nzcgj.cn http://www.morning.mnkz.cn.gov.cn.mnkz.cn