machine learning
|python
一個應變數(
目的:
- 解釋data過去現象
- 利用自變數(
)來預測應變數( )的未來可能數值
方程式:
機器學習-作業4
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv("Salary_Data.csv")
x = dataset.iloc[:, :-1].values
y = dataset.iloc[:, 1].values
'''
# Missing Data
# Categorical Data
'''
# Splitting the Dataset into the Training set and Test set
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=0)
'''
# Feature Scaling
'''
# Simple Linear Regression
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(x_train, y_train)
y_pred = regressor.predict(x_test)
plt.scatter(x_train, y_train, color = 'red')
plt.plot(x_train, regressor.predict(x_train), color = 'blue')
plt.title("Salary vs Experience (training set)")
plt.xlabel("Years of Experience")
plt.ylabel("Salary")
plt.show()
plt.scatter(x_test, y_test, color = 'red')
plt.plot(x_train, regressor.predict(x_train), color = 'blue')
plt.title("Salary vs Experience (testing set)")
plt.xlabel("Years of Experience")
plt.ylabel("Salary")
plt.show()
:::warning ctrl + i 可尋找方法或類別的相關資訊 dataset.info() # 資料類別、是否有缺失資料等資訊 養成習慣: 執行完每列程式後,記得檢查變數是否取用正確 ::: Get the dataset
Oct 29, 2024介紹 假設特徵之間強(樸素)獨立下運用<font color="#3355FF">貝氏定理</font>為基礎的簡單機率分類器 特徵之間為相互獨立的(但現實中不太可能完全獨立),公式為$P(A|X)=\cfrac{P(X|A)*P(A)}{P(X)}$($X$為特徵,$A$為類別) 貝式定理 公式:$P(A|B)=\cfrac{P(B|A)*P(A)}{P(B)}$ $P(A|B)$表示==在B發生的情況下,A發生的機率為何== 例子
May 24, 2023:::info 可參考機器學習 - 多元線性回歸(Multiple Linear Regression) ::: 介紹 方程式:$R^2=1-\cfrac{SS_{res}}{SS_{tot}}$ $R^2$大代表模型是理想的 $R^2$落在0~1之間 自變量不論是否改變,都不會影響<font color=indigo>總平方和$SS_{tot}$</font>,故分母不變
May 17, 2023介紹 <font color="#3355FF">一個</font>應變數($Y$)和<font color="#3355FF">一個或多個</font>自變數($X$)間多項式的回歸分析方式 一個自變量 --> 一元多項式回歸 多個自變量 --> 多元多項式回歸 一元回歸分析中,應變數($Y$)與自變數($X$)為<font color="#008000">非線性關係</font>時,可採用一元多項式回歸 目的: 解釋data過去現象 利用自變數($X$)來預測應變數($Y$)的未來可能數值
May 17, 2023or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up