c# - 不直接随输出缩放的变量的线性回归

标签 c# machine-learning linear-regression

我一直在尝试学习 Coursera 上的机器学习类(class)。到目前为止,大多数引入的线性回归模型都使用其数值与输出呈正相关的变量。

Input: square feet of the house 
Output: house price.

但是,我正在尝试实现一个多元回归模型,其中一些变量的数值与输出不成正比。

Inputs: 
-what day is it (Mon,Tues..), 
-what holiday is it (NewYear,Xmas..), 
-what month is it(Jan,Feb), 
-what time is it(0100,1300..)

Output: 
-Number of visitors.

问题:

  1. 对于变量:今天是哪一天,哪一天是哪一天,哪一个月是哪一个月,我使用枚举并为每个值分配一个值。 (新年=1,圣诞节=2,等等)。这样做更好还是有单独的变量? (是新年、是圣诞节等)

  2. 我知道,通过在变量中应用更高阶的幂,它可以有更好的拟合,这就是我想要的假期变量。有什么方法可以让计算机自己学习最佳顺序吗?

  3. 是否有任何现有的 C# 库可供我使用,允许不同变量使用不同的幂顺序? (例如,假期为 13,一天中的时间为二次)

谢谢。

最佳答案

For the variables: what day is it, what holiday is it, what month is it, I am using an enumeration and assign a value for each value. (NewYear =1, Christmas =2, etc.). Is it better to do it this way or have separate variables? (IsNewYear, IsChristmas, etc.)

是的,你不应该在不遵循算术的变量中编码任何顺序,因此 NewYear=1,Christmas=2,Thanksgiving=3 意味着 Christmas=(Thanksgiving+NewYear)/2...现在你可以这样做想拥有。一种热编码(isNewyear 等)是有利的,因此您不会编码错误的知识

I understand that by applying higher orders of power in a variable, it can have a better fit, which is what I want for the holidays variable. Are there any methods that I can use to let the computer learn the best order by itself?

这就是非线性方法的作用。核方法(核化线性回归、SVR)、神经网络、回归树/森林等。

Are there any existing C# libraries that I can use that allows different orders of power for different variable? (e.g. 13 for holidays and quadratic for the time of the day)

您不应该以这样的方式思考这个问题,您不应该手动适应权力,您应该给模型灵 active 以适应高阶(请参阅上一点)。

关于c# - 不直接随输出缩放的变量的线性回归,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34478691/

相关文章:

c# - 引用自定义 C# 扩展方法的编译器错误

python - keras 模型会影响输入数据的大小吗?

ruby - ruby 中的机器学习算法

r - 在多元线性回归中动态引用列名称 (lm())

c# - IOC 和动态参数

c# - 记录未插入 Access 数据库

python - GridSearchCV 初始化

math - 多元线性回归本质上如何是线性的?

r - 在 R 包 "segmented"中,如何将模型中一条线的斜率设置为 0?

c# - 如何从 C# 中读取中文文本文件?