Six lines of Python is all it takes to write your first machine learning program! In this episode, we’ll briefly introduce what machine learning is and why it’s important. Then, we’ll follow a recipe for supervised learning (a technique to create a classifier from examples) and code it up.

Follow for updates on new episodes!

Subscribe to the Google Developers: –
Subscribe to the brand new Firebase Channel:
And here’s our playlist:

40 thoughts on “Hello World – Machine Learning Recipes #1”

  1. I am fascinated by the ML. My GOD, I tested with many other types of data and it made the correct predictions 99% of the time. Thanks for an amazing concise video. GOOGLE is best in everything.

  2. Would love, LOVE to do this. But you gotta load too much stuff from other places and none of it matches anything shown on the video. Really disappointing.

  3. Fantastic video. Thanks 🙂
    Not sure where did I screw up.
    My output is
    Traceback (most recent call last):
    File "C:/Users/eparsen/WORKSPACE/DEVSPACE/pycharm/ai/", line 7, in <module>
    clf =, features, labels)
    File "", line 739, in fit
    File "", line 122, in fit
    X = check_array(X, dtype=DTYPE, accept_sparse="csc")
    File "", line 382, in check_array
    array = np.array(array, dtype=dtype, order=order, copy=copy)
    TypeError: float() argument must be a string or a number, not 'DecisionTreeClassifier'

  4. I get the following error print clf.predict([[150,0]])
    File "<ipython-input-10-f796bbffbaf0>", line 1
    print clf.predict([[150,0]])
    SyntaxError: invalid syntax
    I am running on windows

  5. Anyone getting syntax error after print. He is using python 2, in 3 you have to use print function with these guys : print(clf.predict([[160,0]]))

  6. What would happen in case of ambiguity in training data , suppose 2 fruits weigh the same or u detect as close to bumy m in reality 1 is still orange n other is apple.How do you solve this..add more features for identification?

  7. I keep failing to import tree :/
    It says it cannot find the tree module, I ran

    import sklearn

    To see if it installed right, but when I do the same for tree it cannot find. Helpppp

  8. #This code work!
    from sklearn import tree
    features = [[140, 1], [130, 1], [150, 0], [170, 0]]
    labels = [0, 0, 1, 1]
    clf = tree.DecisionTreeClassifier()
    clf =, labels)
    print(clf.predict([[150, 0]]))

  9. Man, until I saw this video, I thought machine learning was hard AF. At least now I feel confident I can learn this stuff. Thanks Google – as always.

  10. Great explaining.
    Creepy forced smiles were distracting and unecessary, looked like Mcdonalds "im empty inside" smiles.
    or like a doll smile. (wich is even worse)

Leave a Reply

Your email address will not be published. Required fields are marked *