python三维曲面拟合_用Python拟合多项式曲面

现在,两年后,我可以解决这个问题:

这是一个具有多项式特征的经典回归问题,其中输入变量排列在网格中。在下面的代码中,我手动计算了我需要的多项式特征,分别是这些特征,它们将解释我的目标变量。在import pandas as pd

import numpy as np

from sklearn.linear_model import LinearRegression

import matplotlib.pyplot as plt

from mpl_toolkits.mplot3d import Axes3D

# create random data, which will be the target values

Z = np.random.rand(7,7) * 100

# create a 2D-mesh

x = np.arange(1,8).reshape(7,1)

y = np.arange(1,8).reshape(1,7)

X,Y = np.meshgrid(x,y)

# calculate polynomial features based on the input mesh

features = {}

features['x^0*y^0'] = np.matmul(x**0,y**0).flatten()

features['x*y'] = np.matmul(x,y).flatten()

features['x*y^2'] = np.matmul(x,y**2).flatten()

features['x^2*y^0'] = np.matmul(x**2, y**0).flatten()

features['x^2*y

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值