Learn to Code via Tutorials on Repl.it!

← Back to all posts
Introduction to Machine Learning with Python and Repl.it
h
GarethDwyer1 (274)

Hey all,

I've written a tutorial to explain basic machine learning concepts and to show how to get started with the great Python scikit-learn library.

I hope it helps, especially if you're taking part or wanting to take part in the Repl.it AI competition!

The tutorial is published over here: https://www.codementor.io/garethdwyer/introduction-to-machine-learning-with-python-and-repl-it-rln7ywkhc

As always, keep the feedback coming!

Comments
hotnewtop
mananboi006 (1)

thank you, this helped me a lot...
i was importing machine learning modals from https://machinelearningforkids.co.uk but now i can make my own :p

mananboi006 (1)

@GarethDwyer1 i got a question, i want to get an estimate of how on get the confidence, like how much chance the modal has over the selection? how sure it was when it selected positive one..
It'd be much appreciated if you made a tutorial on that or updated this one.

GarethDwyer1 (274)

@mananboi006 great question - you can use classifier.predict_proba https://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html#sklearn.tree.DecisionTreeClassifier.predict_proba which will give you back a 'score' for each possible label. The predict function just returns the one with the highest score.

I will try to do a follow up on this tutorial to explain how it works with some examples, but for now feel free to shout here i f you don't understand anything

mananboi006 (1)

@GarethDwyer1 i tried that but it gives [[0. 0. 1.]] and basically gives which one of the categories it falls into rather than how sure it is of the category
i want to add a filter so if the program is not sure of the category it choose then it will request a more explained answer from the user

GarethDwyer1 (274)

@mananboi006 It should work! If your data set is very simple (like in the tutorial), then often the leaves will be "pure" and the tree will think that it is certain about its answer.

See https://stackoverflow.com/questions/48219986/decisiontreeclassifier-predict-proba-returns-0-or-1

Try a more complicated / larger dataset or a different classifier.

mananboi006 (1)

its been fixed, i had to limit the depth of the tree, i'll start testing both trees and see if there is a difference in the results with the tree with a limited depth and the one without any limit.

Thank you very much to your time and support.

edit: i guess i'll use the result from no depth limit and then use the probability for the category with the limited depth one