Skip to main content

Posts

Showing posts from May, 2020

A simple introduction to Gradient Descent Algorithm

Gradient Descent is an iterative machine learning optimization algorithm used to reduce the cost function. In machine learning, we use cost function to know the accuracy of our model by using different evaluation metrics to compare our predictions with the known targets. If you need more details on the evaluation metrics, visit my this post  OR if you want to try this in Collab or Binder, visit this link. Gradient Descent can be best explained with the classical analogy of mountain.                   A person is stuck in the mountains and is trying to get down (i.e. trying to find the global minimum). There is heavy fog such that visibility is extremely low. Therefore, the path down the mountain is not visible, so they must use local information to find the minimum. They can use the method of gradient descent, which involves looking at the steepness of the hill at their current position, then proceeding in the direction with the steepest descent (i.e. downhill). If they were tr

Database management with SQLAlchemy

SQLAlchemy is a Python based toolkit and Object Relation Mapper for managing database. To start with, let's install the SQLAlchemy by creating an virtual env first python3 -m venv venv source venv/bin/activate pip install sqlalchemy First thing we do is to import the SQLAlchemy in our project. Then we connect to our database using the create_engine passing the URI of our database. from sqlalchemy import create_engine engine = create_engine('sqlite:///:memory:', echo=True) Typical URL of the database is of the following format :- dialect+driver://username:password@host:port/database In our example, I am just using the in-memory version of the SQLLITE database. Official documentation has very detailed instructions on connecting to database of your choice. Explicit Connectionless Execution : First way of interacting with the database is by running adhoc queries. Here the SQL expressions/query is passed to the execute method of the engine. SQLAlchemy in this