data anlysis and predict
谢邀,本人正在崩溃和兴奋间反复横跳(崩溃居多),anyway, 我心态超好的!besides, 仅供个人学习查阅,不具任何参考价值!!!
(小边不想努力了,来个大佬带飞我吧!
文章目录
- data anlysis and predict
- 1. 工具准备
- 2. 用线性回归做预测
- 3. 分析预测部署
1. 工具准备
- register in
Python anywhere: https://www.pythonanywhere.com/
R: https://rstudio.cloud/
- 本人不知道这两年都对我电脑做了啥,于是我下的是portable压缩包
orange: https://orangedatamining.com/download/#windows
- 会议查询
https://www.ieee.org/conferences/
- jupyter
anaconda prompt
> jupyter notebook
- excel - analysis data 毁灭吧!
file -> option -> add ins -> scroll down -> manage excel add ins -> analysis toolpak
2. 用线性回归做预测
朋友们啊我是真的晕哎
嗯嗯和excel做regression出来的一样~
predict X
Error1: absolute error
E
r
r
o
r
1
=
∣
X
−
X
^
∣
Error1 = |X-\widehat{X}|
Error1=∣X−X
∣
Error2: square error
E
r
r
o
r
2
=
(
X
−
X
^
)
2
Error2 = (X-\widehat{X})^2
Error2=(X−X
)2
代码如下:
X = df.loc[:,["SGD"]]
Y = df.loc[:,['DBS']]
from sklearn import linear_model
model = linear_model.LinearRegression()
model.fit(X,Y)
pred = model.predict(X)
from sklearn.metrics import mean_squared_error
rmse = mean_squared_error(Y,pred)**0.5
print(rmse)
被强大的工具震撼到了
https://cran.r-project.org/bin/windows/base/
3. 分析预测部署
python.anywhere
console -> bash
mkvirtualenv MyFirstVENV
pip install flask
enter MyFirstVENV
in Virtualend in Web
change the flask_app to our code
templates/index.html
<html>
<h1>My First ML cloud - DBS share price prediction</h1>
<form action="/" method="post">
<p>Please enter the exchange rate USD to SGD (eg 1.4)</p>
<p><input type="number" step="0.01" name="rates"></p>
<p><input type="submit" value="Enter"></p>
</form>
<p>The predicted DBS share price {{result}}</p>
</html>
flask_app.py
from flask import Flask, request, render_template
app = Flask(__name__)
@app.route("/", methods=["GET","POST"])
def index():
if request.method == "POST":
rates = float(request.form.get("rates"))
return(render_template("index.html",result=-50.6*rates + 90.2))
else:
return(render_template("index.html",result="WAITING....."))
if __name__ == "__main__":
app.run()
create new directory call templates, upload index in templates directory
go to web, reload
欢迎来看:http://beatles.pythonanywhere.com/