i have a data frame like this
Area | Room | Parking | Warehouse | Elevator | Address | Price |
---|---|---|---|---|---|---|
63 | 1 | True | True | False | Shahran | 61666.67 |
60 | 1 | False | False | False | Shahran | 30083.33 |
79 | 2 | True | False | False | Pardis | 20000.00 |
95 | 2 | False | True | True | Narmak | 71666.67 |
123 | 2 | True | True | True | Zafar | 79000.00 |
and then i change it like this
Area | Room | Parking | Warehouse | Elevator | Address | Price |
---|---|---|---|---|---|---|
63 | 1 | 1 | 1 | 0 | 1 | 61666.67 |
60 | 1 | 0 | 0 | 0 | 1 | 30083.33 |
79 | 2 | 1 | 0 | 0 | 2 | 20000.00 |
95 | 2 | 0 | 1 | 1 | 3 | 71666.67 |
123 | 2 | 1 | 1 | 1 | 4 | 79000.00 |
my “Area” type was str so i change all data fram type to int64 with this code:
Numeric_HDS = coded_address_HDS.astype("int64")
so i want to fitting a curve to my data
-
non-linear
-
multiple linear
for “multiple linear” i think this is the formula:
Y = aX1 + bX2 +cX3 + dX4 + gX5 + hX6
and for “non-linear” i chose:
Y = 1 / 1 + e^beta1(X - beta2)
were X is aX1 + bX2 +cX3 + dX4 + gX5 + hX6
and my code is like this:
def Multiple_Sigmoid_f(beta1, beta2, theta1, theta2, theta3, theta4, theta5, theta6, Numeric_HDS):
Area,Room,Parking,Warehouse,Elevator,Address
= Numeric_HDS[0],Numeric_HDS[1],Numeric_HDS[2],Numeric_HDS[3],Numeric_HDS[4],Numeric_HDS[5]
X = (theta1*Area) + (theta2*Room) + (theta3*Parking) + (theta4*Warehouse) + (theta5*Elevator) + (theta6*Address)
Y = 1 / (1 + np.exp(beta1*(X-beta2)))
return Y
def Multiple_f(theta1, theta2, theta3, theta4, theta5, theta6, Numeric_HDS):
Area,Room,Parking,Warehouse,Elevator,Address
= Numeric_HDS[0],Numeric_HDS[1],Numeric_HDS[2],Numeric_HDS[3],Numeric_HDS[4],Numeric_HDS[5]
Y = (theta1*Area) + (theta2*Room) + (theta3*Parking) + (theta4*Warehouse) + (theta5*Elevator) + (theta6*Address)
return Y
msk = np.random.rand(len(Numeric_HDS)) < 0.8
train = Numeric_HDS[msk]
test = Numeric_HDS[~msk]
X_train = np.asanyarray(train[["Area","Room","Parking","Warehouse","Elevator","Address"]]).transpose()
Y_real_train = np.asanyarray(train["Price"])
I want to fitting a curve but i get “Index error” when using curve_fit
using python
Alireza Rahimi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.