mdabros / SharpLearning

Machine learning for C# .Net
MIT License
383 stars 84 forks source link

Wow! Amazing work! Thanks a lot! #107

Closed flo8 closed 5 years ago

flo8 commented 5 years ago

Hi!

I also wanted to thank you for this wonderful library! The API is super clean and love it so far.

One question I have is regarding the accuracy score like the accuracy_score() function in scikit learn that can be seen here: https://www.kaggle.com/mathvv/prediction-of-red-wine-quality-93-215 Like this: print('Random Forest:', accuracy_score(y_test, rf_pred)*100,'%') Which outputs this: Random Forest: 91.875 %

Many thanks and congrats again!

Flo

mdabros commented 5 years ago

Hi @flo8,

I am glad you like the library! In SharpLearning, the accuracy_score from scikit learn can be computed using the TotalErrorClassificationMetric. In general, SharpLearning returns the "error" rather than the "score" (accuracy in this case). So to get the accuracy, you have to subtract the error from 1.0 and multiply by 100 to get percent, like this:

var metric = new TotalErrorClassificationMetric();
var accuracy = (1.0 - metric.Error(y_test, rf_pred) * 100.0;

In the future, I might add an extension method to the classification metrics so you can get the "score" returned directly. Something like:

var accuracy = metric.Score(y_test, rf_pred);

Best regards Mads

flo8 commented 5 years ago

Hi @mdabros

Thanks for the quick reply, makes sense! Yes the metric.Score() would be nice even if it is indeed very simple to compute with current methods :)

Many thanks

Flo