【发布时间】:2020-01-03 13:31:22
【问题描述】:
我有一个显示某些数据频率的直方图。 我有两种类型的文件:Pdbs 和 Uniprots。每个 Uniprot 文件都与一定数量的 Pdb 相关联。所以这个直方图显示有多少 Uniprot 文件与 0 个 Pdb 文件、1 个 Pdb 文件、2 个 Pdb 文件……80 个 Pdb 文件相关联。 Y 轴采用对数刻度。
我对同一数据集进行了回归,这就是结果。
这是我用于回归图的代码:
# Fitting Simple Linear Regression to the Training set
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
x = np.array(x).reshape((-1, 1))
y = np.array(y)
regressor.fit(x, y)
# Predicting the Test set results
y = regressor.predict(x)
# Visualizing the Training set results
plt.scatter(x, y, color = 'red')
plt.plot(x, regressor.predict(x), color = 'blue')
plt.title('Uniprot vs Pdb')
plt.xlabel('Pdbs')
plt.ylabel('Uniprot')
plt.savefig('regression_test.png')
plt.show()
你能帮我解释一下回归图吗? 我可以理解,随着 Pdb 数量的增加,与它们相关的 Uniprots 将会减少。 但为什么它在 y 轴上变为负数?这正常吗?
【问题讨论】:
-
散点图中的原始数据为红色,表明 uniprot 的原始数据包含负值。回归正确地使用了那些负的 uniprot 值。
标签: matplotlib scikit-learn linear-regression