我有一个".dat"文件,其中保存了X和Y的值(所以一个元组(n,2),其中n是行数).
import numpy as np
import matplotlib.pyplot as plt
import scipy.interpolate as interp
from sklearn import linear_model
in_file = open(path,"r")
text = np.loadtxt(in_file)
in_file.close()
x = np.array(text[:,0])
y = np.array(text[:,1])
Run Code Online (Sandbox Code Playgroud)
我创建了一个实例linear_model.LinearRegression(),但是当我调用.fit(x,y)我得到的方法时
IndexError:元组索引超出范围
regr = linear_model.LinearRegression()
regr.fit(x,y)
Run Code Online (Sandbox Code Playgroud)
我做错了什么?