python图形显示不出来_Python中不会显示图形

我是编程新手,尝试用Python编写图形。但是我遇到了一些错误,图形无法显示。我在Ubuntu操作系统上。希望一些Python专家能够解释什么是错误的以及如何修复它。在

代码:import csv

import numpy as np

from sklearn.svm import SVR

import matplotlib.pyplot as plt

dates = []

prices = []

def get_data(filename):

with open(filename, 'r') as csvfile:

csvFileReader = csv.reader(csvfile)

next(csvFileReader)

for row in csvFileReader:

dates.append(int(row[0].split('-')[0]))

prices.append(float(row[1]))

return

def predict_prices(dates, prices, x):

dates = np.reshape(dates,(len(dates), 1))

svr_lin = SVR(kernel='linear', C=1e3)

svr_poly = SVR(kernel='poly', C=1e3, degree = 2)

svr_rbf = SVR(kernel='rbf',C=1e3, gamma = 0.1)

svr_rbf.fit(dates, prices)

svr_poly.fit(dates, prices)

svr_rbf.fit(dates, prices)

plt.scatter(dates, prices, color='black', label='Data')

plt.plot(dates, svr_rbf.predict(dates), color='red', label='RBF model')

plt.plot(dates, svr_lin.predict(dates), color='green', label='Linear

model')

plt.plot(dates, svr_poly.predict(dates), color='blue', label='Polynomial

model')

plt.xlabel('Date')

plt.ylabel('Price')

plt.title('Support Vector Regression')

plt.legend()

plt.show()

return svr_rbf.predict(x)[0], svr_lin.predict(x)[0], svr_poly.predict(x)

[0]

get_data('aapl.csv')

predicted_price = predict_prices(dates, prices, 29)

print(predicted_price)

从而导致此错误:/home/xxx/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196:

FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值