R တွင် polynomial regression မျဉ်းကွေးကို ဘယ်လိုဆွဲမလဲ။
Polynomial regression သည် ကြိုတင်ခန့်မှန်းကိန်းရှင်နှင့် တုံ့ပြန်မှုကိန်းရှင် သည် linear မဟုတ်သည့်အခါ ကျွန်ုပ်တို့အသုံးပြုသည့် ဆုတ်ယုတ်မှုနည်းလမ်းတစ်ခုဖြစ်သည်။
ဤကျူတိုရီရယ်တွင် R တွင် polynomial regression မျဉ်းကွေးကို မည်သို့ဆွဲရမည်ကို ရှင်းပြထားသည်။
ဆက်စပ်- အဖြစ် အများဆုံး ဆုတ်ယုတ်မှု အမျိုးအစား ၇ ခု
ဥပမာ- R တွင် ကိန်းဂဏာန်း ဆုတ်ယုတ်မှုမျဉ်းကွေးကို ကြံစည်ခြင်း။
အောက်ဖော်ပြပါ ကုဒ်သည် ဒေတာအစုတစ်ခုနှင့် ကိန်းဂဏန်းပမာဏ ဆုတ်ယုတ်မှုပုံစံကို မည်ကဲ့သို့ အံဝင်ခွင်ကျဖြစ်စေကြောင်း ပြသသည်၊ ထို့နောက် ဒေတာကြမ်းပေါ်တွင် ကိန်းဂဏာန်းပြန်ပြောင်းမျဉ်းကွေးကို ကွက်လပ်တစ်ခုတွင် ကွက်ကွက်ပြသသည်-
#define data x <- runif(50, 5, 15) y <- 0.1*x^3 - 0.5 * x^2 - x + 5 + rnorm(length(x),0,10) #plot x vs. y plot(x, y, pch= 16 , cex= 1.5 ) #fit polynomial regression model fit <- lm(y ~ x + I(x^2) + I(x^3)) #use model to get predicted values pred <- predict(fit) ix <- sort(x, index. return = T )$ix #add polynomial curve to plot lines(x[ix], pred[ix], col=' red ', lwd= 2 )
စာသား() လုပ်ဆောင်ချက်ကို အသုံးပြု၍ ကွက်ကွက်တွင် တပ်ဆင်ထားသော ကိန်းဂဏန်းများ ဆုတ်ယုတ်မှုညီမျှခြင်းကိုလည်း ပေါင်းထည့်နိုင်သည်-
#define data x <- runif(50, 5, 15) y <- 0.1*x^3 - 0.5 * x^2 - x + 5 + rnorm(length(x),0,10) #plot x vs. y plot(x, y, pch=16, cex=1.5) #fit polynomial regression model fit <- lm(y ~ x + I(x^2) + I(x^3)) #use model to get predicted values pred <- predict(fit) ix <- sort(x, index. return = T )$ix #add polynomial curve to plot lines(x[ix], pred[ix], col=' red ', lwd= 2 ) #get model coefficients coeff <- round(fit$coefficients, 2) #add fitted model equation to plot text(9, 200 , paste("Model: ", coeff[1], " + ", coeff[2], "*x", "+", coeff[3], "*x^2", "+", coeff[4], "*x^3"), cex= 1.3 )
cex အကြောင်းပြချက်သည် စာသား၏ ဖောင့်အရွယ်အစားကို ထိန်းချုပ်ထားကြောင်း သတိပြုပါ။ မူရင်းမှာ 1 ဖြစ်သောကြောင့် စာသားကိုပိုမိုလွယ်ကူစေရန်အတွက် 1.3 တန်ဖိုးကို အသုံးပြုရန် ရွေးချယ်ခဲ့သည်။
ထပ်လောင်းအရင်းအမြစ်များ
Polynomial Regression နိဒါန်း
Excel တွင် polynomial မျဉ်းကွေးကို မည်ကဲ့သို့ အံကိုက်လုပ်နည်း
Python တွင် polynomial regression လုပ်နည်း