Here's my code:
age=request.user.allusers.age
sex=request.user.allusers.sex
index_array = np.array(states)
index_array = [val-1 for val in index_array]
mask_array = np.zeros(193,dtype=float)
mask_array[index_array] = 1
mask_array=np.append(sex,mask_array)
mask_array=np.append(age,mask_array)
prob_array = clf.predict_proba([mask_array])
In the code sex
is a string. So when compiling the value error is showing up. How can I append sex
in the numpy array.
Here's the error:
ValueError: could not convert string to float: 'Female'