import pandas df = pandas.read_excel('IT行业收入表.xlsx') df.head() X = df[['工龄']] Y = df['薪水'] from matplotlib import pyplot as plt plt.rcParams['font.sans-serif'] = ['SimHei'] plt.scatter(X, Y) plt.xlabel('工龄') plt.ylabel('薪水') plt.show() from sklearn.linear_model import LinearRegression regr = LinearRegression() regr.fit(X, Y) import numpy as np X = np.array(X) plt.scatter(X, Y) plt.plot(X, regr.predict(X), color='red') plt.xlabel('工龄') plt.ylabel('薪水') plt.show()
两个图都运行出来了,但是不知道警告的原因?