y_p:::python在这个(或任何)脚本中做什么?
我正在努力完成Sebastian Raschka关于特性缩放的教程,但我无法运行下面的代码,因为它抛出并错误地显示了第三行,即以“python”结尾的代码y_p:::python在这个(或任何)脚本中做什么?,python,python-2.7,numpy,matplotlib,Python,Python 2.7,Numpy,Matplotlib,我正在努力完成Sebastian Raschka关于特性缩放的教程,但我无法运行下面的代码,因为它抛出并错误地显示了第三行,即以“python”结尾的代码 from matplotlib import pyplot as plt fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(nrows=2, ncols=2, figsize=(10,5)) y_p :::python # Standardization x = [1,4,5
from matplotlib import pyplot as plt
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(nrows=2, ncols=2, figsize=(10,5))
y_p :::python
# Standardization
x = [1,4,5,6,6,2,3]
mean = sum(x)/len(x)
std_dev = (1/len(x) * sum([ (x_i - mean)**2 for x_i in x]))**0.5
z_scores = [(x_i - mean)/std_dev for x_i in x]
# Min-Max scaling
minmax = [(x_i - min(x)) / (min(x) - max(x)) for x_i in x]os = [0 for i in range(len(x))]
ax1.scatter(z_scores, y_pos, color='g')
ax1.set_title('Python standardization', color='g')
ax2.scatter(minmax, y_pos, color='g')
ax2.set_title('Python Min-Max scaling', color='g')
ax3.scatter(z_scores_np, y_pos, color='b')
ax3.set_title('Python NumPy standardization', color='b')
The-effect-of-standardization
ax4.scatter(np_minmax, y_pos, color='b')
ax4.set_title('Python NumPy Min-Max scaling', color='b')
plt.tight_layout()
for ax in (ax1, ax2, ax3, ax4):
ax.get_yaxis().set_visible(False)
ax.grid()
plt.show()
那么,y_p::python做什么 答案是它不是有效的python代码 你应该看看ipython笔记本,我相信你从中获得了部分代码 相关的代码片段是
from matplotlib import pyplot as plt
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(nrows=2, ncols=2, figsize=(10,5))
y_pos = [0 for i in range(len(x))]
ax1.scatter(z_scores, y_pos, color='g')
ax1.set_title('Python standardization', color='g')
这很有趣。实际上,我使用的代码来自网站:但是你链接到的笔记本更干净。也许它是用来把网站转换成笔记本之类的?不管怎样,谢谢你帮我澄清。我很感激。很明显,HTML导出被搞砸了