Python深度學習筆記(一):使用TensorFlow建立神經網路進行PM2.5預測

神經網路

引入模組與資料

import pandas as pd  
import numpy as np
import tensorflow as tf
from sklearn.metrics import explained_variance_score,mean_absolute_error,median_absolute_error
from sklearn.model_selection import train_test_split

查看資料訊息

df.describe().T
df.info()

選擇要預測的標籤

X = df[['SO2', 'CO', 'O3', 'Nox', 'NO', 'NO2', 'THC', 'NMHC', 'CH4', 'WindSpeed','TEMP','Humidity']]

分成測試集和訓練集

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=23)

TensorFlow

#使用TensorFlow選擇特徵
feature_cols = [tf.feature_column.numeric_column(col) for col in X.columns]
The Explained Variance: 0.96
The Mean Absolute Error: 2.17
The Median Absolute Error: 1.55

Written by

Machine Learning / Deep Learning / Python / Flutter cakeresume.com/yanwei-liu

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store