我在python中有以下信息(数据帧)
product baskets scaling_factor
12345 475 95.5
12345 108 57.7
12345 2 1.4
12345 38 21.9
12345 320 88.8
Run Code Online (Sandbox Code Playgroud)
我想运行以下非线性回归并估计参数.
a,b和c
我想要适合的等式:
scaling_factor = a - (b*np.exp(c*baskets))
Run Code Online (Sandbox Code Playgroud)
在sas中我们通常运行以下模型:(使用高斯牛顿法)
proc nlin data=scaling_factors;
parms a=100 b=100 c=-0.09;
model scaling_factor = a - (b * (exp(c*baskets)));
output out=scaling_equation_parms
parms=a b c;
Run Code Online (Sandbox Code Playgroud)
有没有类似的方法来估计Python中的参数使用非线性回归,我怎么能看到python中的情节.
我正在尝试将数据帧传输到oracle数据库,但是传输时间太长,因为变量的数据类型在oracle中显示为clob。但是我相信,如果我将数据类型从clob转换为带有填充0的9位字符串,则不会花费那么多时间。数据是
product
000012320
000234234
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以将此变量的数据类型更改为9位数字的字符串。因此,oracle不会将其视为CLOB对象。我已经尝试了以下。
df['product']=df['product'].astype(str)
Run Code Online (Sandbox Code Playgroud)
还是有其他东西可能会减慢从python到oracle的传输?
我有两列,只想保留非交换行.对于下面的数据,我的输出应该包含一个(1 2)的组合.即我的查询(1 2)与(2 1)相同.有没有一种简单的方法在R中做到这一点.已经尝试过调换.并保留上部的traingular矩阵.但转移数据变得很痛苦.
A B prob
1 2 0.1
1 3 0.2
1 4 0.3
2 1 0.3
2 3 0.1
2 4 0.4
Run Code Online (Sandbox Code Playgroud)
我的最终输出应该是:
A B prob
1 2 0.1
1 3 0.2
1 4 0.3
2 3 0.1
2 4 0.4
Run Code Online (Sandbox Code Playgroud)