發表文章

目前顯示的是有「資料前處裡」標籤的文章

使用線性回歸模型進行訓練及預測_(波士頓房價)_透過偏度(skewness)修正來提升預測準確度

圖片
沿用上一篇 EDA 先抓取到的波士頓房價資料,封裝額外一個python檔案。 getData.py from sklearn.datasets import load_boston import pandas as pd display = pd . options . display display . max_columns = None display . max_rows = None display . width = None display . max_colwidth = None def getRawData (): data = load_boston() df = pd . DataFrame(data = data . data,columns = data . feature_names) df . insert( 0 ,column = 'PRICE' ,value = data . target) print (data . DESCR) return df 訓練階段.ver1 train_model.py 訓練存出模型二進位檔 import pickle import pandas as pd from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split from getData import getRawData import numpy as np df = getRawData() data = np . c_[df[ 'LSTAT' ] ,df[ 'RM' ]] x = pd . DataFrame(data = data,columns = [ 'LSTAT' , 'RM' ]) #特徵集合 y = df[ 'PRICE' ] #進行訓練資料跟測試資料分割 #80% 訓練用 / 20%測試用,訓練好的模型,可以使用剩餘20%的test來進行驗證,並計算分數。 ...

探索式資料分析EDA_皮爾森積差相關係數(波士頓房價)_熱度圖&散點圖

圖片
  這邊要先確保sklearn使用版本要是1.1.3版本(之後版本都移除波士頓房價的toy dataset了) 然後numpy不能到2.x版本 要是1.26.4 https://stackoverflow.com/questions/78634235/numpy-dtype-size-changed-may-indicate-binary-incompatibility-expected-96-from Attribute Information (in order):         - CRIM     per capita crime rate by town         - ZN       proportion of residential land zoned for lots over 25,000 sq.ft.         - INDUS    proportion of non-retail business acres per town         - CHAS     Charles River dummy variable (= 1 if tract bounds river; 0 otherwise)         - NOX      nitric oxides concentration (parts per 10 million)         - RM       average number of rooms per dwelling         - AGE      proportion of owner-occupied units built prior to 1940     ...