1

I used logistic regression with python and got an accuracy score of 95%, how do I get this equation so that I can actually implement it?

I wrote:

model = LogisticRegression()
model.fit(train_X,train_y)
prediction=model.predict(test_X)
print('Accuracy:', "\n", '%',metrics.accuracy_score(prediction,test_y) * 100)

and my output was:

Accuracy: %95.5555555556

Christian
  • 83
  • 4
  • A little more context will help: sklearn? Or something else? What do you want to implement? Or do you want to use the trained classifer on some test data? – doctorlove Apr 16 '18 at 15:25
  • I just want to find the equation that it used to get the 95% accuracy. For example, using the iris data set that shows pedal/sepal length, I want to be able to use the formula to create a form that people can enter their data and it will predict it – Christian Apr 16 '18 at 15:32
  • 1
    Then use `model.predict` on some other data? It has the model inside - which David's answers tells you how to get the details of. You don't need to re-code it. – doctorlove Apr 16 '18 at 15:38

2 Answers2

2

The model object has an attribute called coef_ where the coefficients of the model are stored. In addition, the attribute intercept_ gives the intercept of the model.

David Masip
  • 2,146
  • 1
  • 26
  • 46
0

I'm assuming you're using SkLearn. But what do you mean by implement it? Are you looking to write it into a separate language, or use a different library (i.e. TensorFlow)?

If you just want to keep the model and use it in a python program later, you can save and load it with Pickle.