data analysis and predict

data anlysis and predict

谢邀,本人正在崩溃和兴奋间反复横跳(崩溃居多),anyway, 我心态超好的!besides, 仅供个人学习查阅,不具任何参考价值!!!

(小边不想努力了,来个大佬带飞我吧!

文章目录

  • data anlysis and predict
    • 1. 工具准备
    • 2. 用线性回归做预测
    • 3. 分析预测部署

1. 工具准备

  1. register in

Python anywhere: https://www.pythonanywhere.com/
R: https://rstudio.cloud/

  1. 本人不知道这两年都对我电脑做了啥,于是我下的是portable压缩包

orange: https://orangedatamining.com/download/#windows

  1. 会议查询

https://www.ieee.org/conferences/

  1. jupyter

anaconda prompt

> jupyter notebook
  1. excel - analysis data 毁灭吧!

file -> option -> add ins -> scroll down -> manage excel add ins -> analysis toolpak

2. 用线性回归做预测

朋友们啊我是真的晕哎

data analysis and predict_第1张图片

嗯嗯和excel做regression出来的一样~

data analysis and predict_第2张图片

predict X

data analysis and predict_第3张图片

Error1: absolute error
E r r o r 1 = ∣ X − X ^ ∣ Error1 = |X-\widehat{X}| Error1=XX
Error2: square error
E r r o r 2 = ( X − X ^ ) 2 Error2 = (X-\widehat{X})^2 Error2=(XX )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)

被强大的工具震撼到了

data analysis and predict_第4张图片

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 predictionh1>
    <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/

你可能感兴趣的:(ML,python,flask,开发语言)