我想为以下公式创建一个函数,这些公式用于估算R中支持向量回归的元参数,但是运行该函数后出现错误。
费用公式
import tkinter as tk
class Window(tk.Frame): # <-- avoid star imports
def __init__(self, master=None):
self.master = master
super().__init__(master, bg='LightBlue') # <-- use super instead of hardcoding the parent class
self.init_window()
def init_window(self):
self.master.title("GUI")
self.master.geometry('400x400')
self.pack(fill=tk.BOTH, expand=True)
self.quit_button = tk.Button(self, text='Quit',
command=self.master.destroy)
self.quit_button.pack()
if __name__ == '__main__':
root = tk.Tk()
app = Window(root)
root.mainloop()
C=max(|mean(y) - 3 standard deviaion(y)|,|mean(y) - 3 standard deviaion(y)|)
错误如下
Cost <- function(mean_y, sd_y){
max(|mean_y-3*sd_y|,|mean_y-3*sd_y|)
}
答案 0 :(得分:0)
为了避免出现错误,我发现解决方案是这样的:
Cost <- function(mean_y, sd_y)
{
abs(max(mean_y-3*sd_y,mean_y-3*sd_y))
}
mean<-mean(data$AWC)
sd<-sd(data$AWC)
C<-Cost(mean_y = mean, sd_y = sd)
#result
[1] 1.865534