packages = ["pandas", "scikit-learn", "numpy"]
気象庁 天気予報
データを登録
天気痛を予測
データを閲覧
初期化
ヘルプ
戻る
日時:
時刻:
地域:
天気:
最高気温:
最低気温:
温度:
湿度:
気圧:
登録
戻る
戻る
import pandas as pd
import numpy as np
from sklearn import svm
from pyodide.http import open_url
from pyodide import create_proxy
from sklearn.preprocessing import MinMaxScaler
url = "https://mukai-lab.info/application/WeatherPainApp/data/data-oversampling.csv"
resampled_df = pd.read_csv(open_url(url))
X = np.array(resampled_df[["temperature", "humidity", "pressure"]])
Y = np.array(resampled_df["pain"])
mms = MinMaxScaler()
scaler = mms.fit(X)
x = scaler.transform(X)
svc = svm.SVC(probability=True, C=100, gamma=1.0, kernel="rbf", random_state=0)
svc.fit(x, Y)
def setup():
function_proxy = create_proxy(runSVM)
document.getElementById("bt_svm").addEventListener("click", function_proxy);
def runSVM(event):
prediction_temperature = int(Element("prediction-temperature").element.value);
prediction_humidity = int(Element("prediction-humidity").element.value);
prediction_pressure = int(Element("prediction-pressure").element.value);
console.log(str(prediction_temperature) + "," + str(prediction_humidity) + "," + str(prediction_pressure))
x = scaler.transform([[prediction_temperature, prediction_humidity, prediction_pressure]])
probability = svc.predict_proba(x)
probability_text = str("{:.2f}".format(probability[0][1] * 100))
prediction_result = Element("prediction-result")
prediction_result.element.innerText = "天気痛の確率は" + probability_text + "%"
setup()
戻る
接続方法
- ブラウザはChromeを利用する
- Chromeでchrome://flags/にアクセスしExperimental Web Platform featuresを有効にする
- Chromeを再起動する
参考