【发布时间】:2020-11-30 19:39:57
【问题描述】:
我正在尝试为成分数据构建一个简单的线性回归示例。我正在使用以下代码:
from pandas import DataFrame
import numpy as np
from skbio import TreeNode
from gneiss.regression import ols
from IPython.display import display
#define table of compositions
yTrain = DataFrame({'y1': [0.8, 0.3, 0.5], 'y2': [0.2, 0.7, 0.5]})
#define predictors for compositions
xTrain = DataFrame({'x1': [1,3,2]})
#Once these variables are defined, a regression can be performed. These proportions will be converted to balances according to the tree specified. And the regression formula is specified to run temp and ph against the proportions in a single model.
model = ols('x1', yTrain, xTrain)
model.fit()
xTest = DataFrame({'x1': [1,3]})
yTest = model.predict(xTest)
display(yTest)
我收到错误 matrices are not aligned。关于如何让它运行的任何想法?
【问题讨论】:
标签: python linear-regression statsmodels coda