資源簡介
經典模型對應的python代碼經典模型對應的python代碼

代碼片段和文件信息
import?numpy?as?np
import?matplotlib.pyplot?as?plt
#?Read?dataset
x?y?=?[]?[]
for?sample?in?open(“../_Data/prices.txt“?“r“):
????xx?yy?=?sample.split(““)
????x.append(float(xx))
????y.append(float(yy))
x?y?=?np.array(x)?np.array(y)
#?Perform?normalization
x?=?(x?-?x.mean())?/?x.std()
#?Scatter?dataset
plt.figure()
plt.scatter(x?y?c=“g“?s=20)
plt.show()
x0?=?np.linspace(-2?4?100)
#?Get?regression?model?under?LSE?criterion?with?degree?‘deg‘
def?get_model(deg):
????return?lambda?input_x=x0:?np.polyval(np.polyfit(x?y?deg)?input_x)
#?Get?the?cost?of?regression?model?above?under?given?x?y
def?get_cost(deg?input_x?input_y):
????return?0.5?*?((get_model(deg)(input_x)?-?input_y)?**?2).sum()
#?Set?degrees
test_set?=?(1?4?10)
for?d?in?test_set:
????print(get_cost(d?x?y))
#?Visualize?results
plt.scatter(x?y?c=“g“?s=20)
for?d?in?test_set:
????plt.plot(x0?get_model(d)()?label=“degree?=?{}“.format(d))
plt.xlim(-2?4)
plt.ylim(1e5?8e5)
plt.legend()
plt.show()
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\
?????文件????????1184??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\.gitignore
?????目錄???????????0??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Data\
?????文件?????????120??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Data\balloon1.0(en).txt
?????文件?????????438??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Data\balloon1.0.txt
?????文件?????????438??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Data\balloon1.5.txt
?????文件?????????424??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Data\balloon2.0.txt
?????文件?????5604839??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Data\bank1.0.txt
?????文件?????8559529??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Data\cifar10.txt
?????文件?????5205193??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Data\madelon.txt
?????文件?????8103179??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Data\mnist.txt
?????文件??????373704??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Data\mushroom.txt
?????文件?????????563??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Data\prices.txt
?????文件?????????379??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Data\test.txt
?????目錄???????????0??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\
?????目錄???????????0??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\ImageRecognition\
?????目錄???????????0??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\ImageRecognition\_Data\
?????目錄???????????0??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\ImageRecognition\_Data\_Cache\
?????文件??????????80??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\ImageRecognition\_Data\_Cache\LABEL_DIC.npy
?????文件???????????0??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\ImageRecognition\_Data\Put?Training?Dataset?FOLDERS?here
?????文件????????6108??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\ImageRecognition\Main.py
?????目錄???????????0??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\ImageRecognition\Models\
?????目錄???????????0??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\ImageRecognition\Models\Extractors\
?????目錄???????????0??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\ImageRecognition\Models\Extractors\v3\
?????文件???????????0??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\ImageRecognition\Models\Extractors\v3\Put?v3?Extractor?here?as?‘Model.pb‘
?????文件????????2946??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\ImageRecognition\README.md
?????目錄???????????0??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\ImageRecognition\Test\
?????文件???????????0??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\ImageRecognition\Test\Put?testing?pictures?here
?????文件???????19644??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\ImageRecognition\ToolBox.py
?????目錄???????????0??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\NeuralNetworks\
?????目錄???????????0??2018-06-21?15:25??MachineLearning-master\MachineLearning-master\_Dist\NeuralNetworks\_Tests\
............此處省略278個文件信息
評論
共有 條評論