Srishino
Srishino

Reputation: 61

Output required in float data type from Logistic regression

I am using sklearn.linear_model import LogisticRegression. The features in my data are in 'int' and 'float' values both. While the outcome is also of float data type, the final y_predict is printed in integer values. I am using the following code-

from sklearn.model_selection import train_test_split 
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size = 0.30)
y=y.astype('float')  
X_train.shape
from sklearn.linear_model import LogisticRegression
Lr=LogisticRegression()
Lr.fit(X_train,y_train)
y_predict=Lr.predict(X_test)   
df1=pd.DataFrame({"Actual":y_test, "Predicted":y_predict})        

I want the actual and predicted values in float but it is giving the output in int data type. How can I get exact actual values of y_test(which are of float type, my input data) and so the predicted values also in float data type. Sample output(eg.) : Actual Predicted 2 2 Required(eg.): Actual Predicted 1.234 1.234

Upvotes: 1

Views: 1879

Answers (1)

thorntonc
thorntonc

Reputation: 2126

Logistic regression provides a constant output. If you want a continuous output consider using a model like linear regression. Also consider using predict_proba instead of predict. This will give you the probabilities for the target in array form.

Upvotes: 1

Related Questions