相关疑难解决方法(0)

Python:来自3个列表的2d等高线图:x,y和rho?

我在python和matplotlib中有一个简单的问题.我有3个列表:x,y和rho,其中rho [i]是点x [i],y [i]处的密度.x和y的所有值都在-1之间.1.但它们没有特定的顺序.

如何制作密度rho的轮廓图(如imshow)(在点x,y处插值).

非常感谢你.

编辑:我使用大型数组:x,y和rho有10,000到1,000,000个元素

python matplotlib contour

28
推荐指数
2
解决办法
6万
查看次数

Python numpy的线性回归

我试图做一个简单的线性回归函数,但继续遇到一个

numpy.linalg.linalg.LinAlgError:奇异矩阵错误

现有功能(带调试打印):

def makeLLS(inputData, targetData):
    print "In makeLLS:"
    print "    Shape inputData:",inputData.shape
    print "    Shape targetData:",targetData.shape
    term1 = np.dot(inputData.T, inputData)
    term2 = np.dot(inputData.T, targetData)
    print "    Shape term1:",term1.shape
    print "    Shape term2:",term2.shape
    #print term1
    #print term2
    result = np.linalg.solve(term1, term2)
    return result
Run Code Online (Sandbox Code Playgroud)

使用我的测试数据输出到控制台是:

In makeLLS:
    Shape trainInput1: (773, 10)
    Shape trainTargetData: (773, 1)
    Shape term1: (10, 10)
    Shape term2: (10, 1)
Run Code Online (Sandbox Code Playgroud)

然后它在linalg.solve线上出错.这是一本教科书线性回归函数,我似乎无法弄清楚为什么它会失败.

什么是奇异矩阵误差?

python numpy linear-regression

7
推荐指数
2
解决办法
4万
查看次数

标签 统计

python ×2

contour ×1

linear-regression ×1

matplotlib ×1

numpy ×1