- 博客(8)
- 收藏
- 关注
原创 选择排序(Java实现)
一种最简单的排序算法是这样的:首先,找到数组中最小的那个元素,其次,将它和数组的第一个元素交换位置(如果第一个元素就是最小元素那么它就和自己交换)。再次,在剩下的元素中找到最小的元素,将它与数组的第三个元素交换位置。如此往复,直到将整个数组排序。这种方法叫做选择排序,因为它在不断地选择剩余元素之中的最小者。如算法代码所示,选择排序的内循环只是在比较当前元素与目前已知的最小元素(以及将当前索引加1和检查是否代码越界),这已经简单到了极点。交换元索的代码写在内循环之外,每次交换都能排定一个元素,因此交换的总.
2021-11-16 15:08:21 98
原创 吴恩达机器学习编程题四(神经网络-BP)(python)
import numpy as npimport scipy.io as sioimport matplotlib.pyplot as pltfrom scipy.optimize import minimizedata = sio.loadmat('ex4data1.mat')raw_X = data['X']raw_y = data['y']X=np.insert(raw_X,0,values=1,axis=1)X.shapedef one_hot_encoder(raw_y):
2021-10-23 10:45:57 2205
原创 吴恩达机器学习编程题三(神经网络-向前传播)(Python)
import numpy as npimport scipy.io as siodata = sio.loadmat('ex3data1.mat')raw_X = data['X']raw_y = data['y']X = np.insert(raw_X,0,values=1,axis=1)X.shapey = raw_y.flatten()y.shapetheta = sio.loadmat('ex3weights.mat')theta.keys()theta1 = t
2021-10-09 19:59:54 185
原创 吴恩达机器学习编程题三(逻辑回归解决多分类问题)(Python)
import numpy as npimport matplotlib.pyplot as pltimport scipy.io as siodata = sio.loadmat('ex3data1.mat')dataprint(type(data))data.keys()raw_X = data['X']raw_y = data['y']print(raw_X.shape,raw_y.shape)def plot_an_image(X): ...
2021-10-09 19:57:01 221
原创 吴恩达机器学习编程题二(线性不可分案例)(Python)
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltpath = 'ex2data2.txt'data = pd.read_csv(path, names=['Test 1', 'Test 2', 'Accepted'])data.head()fig, ax = plt.subplots()ax.scatter(data[data['Accepted'] == 0]['Test 1'], data[dat.
2021-10-07 20:26:30 128
原创 吴恩达机器学习编程题二(线性可分案例)(Python)
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltpath = 'ex2data1.txt'data = pd.read_csv(path, names=['Exam 1', 'Exam 2', 'Accepted'])data.head()fig, ax = plt.subplots()ax.scatter(data[data['Accepted'] == 0]['Exam 1'], data[dat.
2021-10-07 20:25:02 76
原创 吴恩达机器学习编程题一(多变量线性回归)(Python)
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltdata = pd.read_csv('ex1data2.txt', names=['size', 'bedrooms', 'price'])print(data.head())def normalize_feature(data): return (data - data.mean()) / data.std()data = normali.
2021-10-07 20:16:16 83
原创 吴恩达机器学习编程题一(单变量线性回归)(Python)
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltpath = 'ex1data1.txt'data = pd.read_csv(path, names=['Population', 'Profit'])print(data.head())print(data.describe())data.plot(kind='scatter', x='Population', y='Profit', label=.
2021-10-07 20:05:05 156
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人