Tag: ML

  • Saving trained model

    Saving trained model

    In most cases, for training the model with the dataset we have is very time consuming and also processing hungry job which is costly task. To test in our development environment we have to do is test the trained model or use the trained model for in production without going for multiple training.

    If you have done some ML project you would have understood, how time and processor consuming task it is even when done in GPUs. For a application to use the model and train each time the application runs is unacceptable, so we can save the current trained state of the model for later use without of retraining the model on the same dataset again and again.

    We can accomplish this in python using some packages like

    • Pickle (Python Object Serialization Library)
    • Joblib (One of the Scikit-learn Method)

    Pickle?

    You might have heard this term somewhere when you go though ML articles or doing projects. This library is popular for Serialization(Pickling) and Marshalling (Unpickling). Pickling is the process of converting any Python object into a stream of bytes in hierarchy.Unpickling is process of converting the pickled stream of bytes to original python object following the object hierarchy.

    Example:

    Serialization (Pickling)

    import pickle
    
    pickle_file = 'string_list_pickle.pkl'
    names = ['apple', 'ball', 'cat']
    
    store_pickle = open(pickle_file, 'wb')
    pickle.dump(names, store_pickle)
    store_pickle.close()
    (more…)
  • Simple Neural Network for absolute beginners

    This is my first post regarding artificial intelligence (AI). But I promise to include as much as I can from understanding Simple Neural Network (NN) to deep learning through little theoretical but lots of practical implementations. I will also include simple projects where possible. Lets begin building then.

    I like Python a lot so most of the works will be done in Python. Later on I am hoping to develop them in Java and Scala.

    To learn NN we will not be using any NN libraries but some mathematical libraries, ie. numpy.

    Learn basics of Numpy HERE .

    To begin building NN which is supposed to mimic how our brain works, we have to understand little bit of our own Brain.

    An averaged sized Brain includes of 100 billion neurons connected by synapses. Neurons are the basic unit of brain which plays major role for all the tasks done by brain.  Blah blah blah… its better you go through this well written article (A Basic Introduction To Neural Networks).

    This tutorial we will be building a Artificial unit of this very Neuron. I consider you know matrices which we will be using as mathematical foundation for building NN with numpy.

    Our simple ANN will include three inputs and a output. (Input: 3, Output: 1). This neuron we will build should classify a basic problem of classification. We will use various different training algorithms to train our neuron for classification.

    So our neuron will have very small dataset for training (a deeplearning model will need very very large dataset for better performance) which will be enough in this problem.

    Example#Input AInput BInput COutput Y
    10010
    21111
    31011
    40110
    5100??? (1 expected)

    So what will be the output for the last data row (Row #5)?.

    (more…)