本帖最后由 WyattHuang 于 2018-9-20 07:46 编辑
post on 20180919
FBI WARNING
此模型仅供参考 !!!
This model is for reference only !!
因为这个预测模型是我刚接触到机器学习的时候和同学sao做的,
所以论文和代码里面可能会有一些错误的观点,请谅解 ![](https://static.52pojie.cn/static/image/smiley/default/14.gif)
此帖的意义只是给想大家分享一下 人工智能给我们生活带来的的便利
代码是用我大Python编写的
Abstract:
To predict the future gasoline price to help the consumer select the amount of
the oil he should purchase in advance, accroding to our analysis, we decide to
use python with Sk-learn base to write a program. This program is able to
"learn" the law through a large amount of inf ormation, then use the same law to
inf er and predict the details of those probable changes in the f uture. Theref ore,
we just provide various historical databef ore 2012 about the gasoline price f rom
the wabsites to the program. Af ter we run the code 9 times by respctively using
9 kinds of f unctions that is used to predict this type of data which is
continuious and compare those figures which are tested and can only be seen
by us with the ture figure of oil price, we finally get the most eff ective f unction-
-"SVM", which off ers the figure that has the highest similarity. Then, it becomes
the core algorithm of our model. Finally, the consumer can make decisions with
the help of our figure which is the simplified version of tested figures easily, no
matter how long the consumer is going to drive per week.
Keywords: Gasoline; Price; Prediction; Sk-learn; Historical data;
论文 + 数据 下载 链接:https://pan.baidu.com/s/1k2p28HysPTWXGrfzqZ-Krw 密码:og8k
源码 [Python] 纯文本查看 复制代码 '''
You'd better execute this code in Linux!
'''
from __future__ import print_function
from sklearn import datasets
from sklearn.cross_validation import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn import preprocessing
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import sys
sys.setrecursionlimit(99999)
import time
'''
同学的骚操作
'''
from progressbar import *
total = 1000
def dosomework():
time.sleep(0.01)
progress = ProgressBar()
for i in progress(range(1000)):
dosomework()
'''
载入数据
'''
data_his=pd.read_excel("bin\history.xlsx")#历史
data_his.fillna(value=-99999,inplace=True)
data_cur=pd.read_excel("current.xlsx")#当前
data_cur.fillna(value=-99999,inplace=True)
'''
拆分数据
'''
learn_x=np.delete(data_his.values,['0','1','5','6',],axis=1)
learn_y=np.delete(data_his.values,['0','2','3','4','5','6'],axis=1)
learn_x=np.delete(learn_x,[0],0)
learn_y=np.delete(learn_y,[0],0)
pre_y=np.delete(data_cur.values,['0',"1",'5','6'],axis=1)
pre_y=np.delete(pre_y,[0],0)
'''
载入学习模型
'''
from sklearn import svm
model_SVR = svm.SVR()
'''
学习历史数据
'''
model_SVR.fit(learn_x,learn_y)
'''
预测数据
'''
result=model_SVR.predict(pre_y)
'''
输出结果及绘图
'''
print(result)
plt.figure()
plt.title('Predict Value: '+str(result))
plt.plot(np.arange(len(result)),result,'ro-',label='predict value')
plt.legend()
plt.show() |