我的线性回归模型无法适应,需要2D数组

2024-06-16 15:06:50 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我有两个1D数组,我需要绘制它们的线性回归模型,以了解它们的趋势,所以我有以下代码:

from brian2 import *
%matplotlib inline
from sklearn.linear_model import LinearRegression

start_scope()

reg = LinearRegression()
reg.fit(rates, R)
reg.coef_

#rates and R were issued beforehand

figure(figsize=(36,12))
subplot(121)
plot(rates,R,'o','b',reg,'r' )
xlabel('Time (ms)')
ylabel('V (mV)')
title("M.I. - firing rate evolution")
ylim((0,35))

然后我得到一个错误:

^{pr2}$

有人能帮我理解吗?在


Tags: 代码from模型importmatplotlib绘制inline线性