MySQL meets Python

MySQL is an open-source relational database management system (RDBMS). Here we will learn how to setup MySQL in ubuntu and use it with the help of Python. Thanks to w3schools.

Flask and Cookies

HTTP cookies (also called web cookies, Internet cookies, browser cookies, or simply cookies) are small blocks of data created by a web server while a user is browsing a website and placed on the user’s computer or other device by the user’s web browser. Cookies are placed on the device used to access a website, and more than one cookie may be placed on a user’s device during a session.

Here we will learn to use cookies with flask.

Flask with Jinja

A simple headline website that uses RSS feeds to display the news from 7 news outlets. ‘feedparser’ library is used to parse the RSS feeds. ‘jinja’ is used to form html templates dynamically.

Flask Intro..

Flask is a web application framework written in Python. Armin Ronacher, who leads an international group of Python enthusiasts named Pocco, develops it. Flask is based on Werkzeug WSGI toolkit and Jinja2 template engine. Both are Pocco projects.
This tutorial is a first in series of tutorials about building a web application using Flask.

Double Deep Q-Network

In double DQNs, we use a separate network to estimate the target rather than the prediction network. The separate network has the same structure as the prediction network. And its weights are fixed for every T episode (T is a hyperparameter we can tune), which means they are only updated after every T episode. The update is simply done by […]

Climbing the Mountain with Neural Network

Function Approximation For problems with very large number of states it will not be feasible for our agent to use table to record the value of all the action for each state and make its policy accordingly. In Function approximation agent learns a function which will approxmately give it best action for particular state. In this example we will use […]

SARSA in the Wind

We will use SARSA algorithm to find the optimal policy so that our agent can navigate in windy world. SARSA State–action–reward–state–action (SARSA) is an algorithm for learning a Markov decision process policy, used in the reinforcement learning area of machine learning. SARSA focuses on state-action values. It updates the Q-function based on the following equation: Q(s,a) = Q(s,a) + α (r + γ Q(s’,a’) – Q(s,a)) Here s’ […]

Balancing pole with Policy Gradient

The policy gradient algorithm trains an agent by taking small steps and updating the weight based on the rewards associated with those steps at the end of an episode. The technique of having the agent run through an entire episode and then updating the policy based on the rewards obtained is called Monte Carlo policy gradient. The action is selected […]

Cross Tabulation in Pandas

The data Importing the Library and loading the data Crosstab Basic Selection with .loc and .iloc Using basic function with cross tab Margins are for total Normalizing Results Aggregate function Sorting Unique values Visualization Plotting

Logistic Regression in PyTorch

Load the Data Converting each column data to numpy array From numpy array to pytorch tensor Plotting the data Using the GPU Defining the neural network Putting neural network on GPU Loss function Setting ADAM as an optimizer Defining accuracy The main loop Plotting Loss Plotting accuracy After one epoch Plots to show performance of neural network over epochs

Basic Neural Network in PyTorch

Making a simple neural network with a single hidden layer and four neurons in hidden layer. Schema of our Neural Network Import necessary libraries Inputs and outputs Converting basic python array to PyTorch tensors Code to use GPU if available Putting our variable to GPU Defining neural network instantiate neural network Weights of different layers Loss function Only one forward […]

PyTorch Tensors

This blog post contains following topics related to tensors: Import Version Declarations item() Zero, identity and linspace Random generator Datatypes Operation with constant Element wise operations Matrix multiplication Matrix inversion Transpose of matrix Determinant of matrix Indexing and slicing Broadcasting Reshape Squeeze and unsqueeze Concatenate and stack Reorganize the data element numpy and pytorch tensor Operations on complex numbers Import […]

2 in One Neural Network

Here we present a 2 in one network. A neural network which does regression and classification at same time. Iris data set has been used in this example Loading the dataset Shuffle the dataframe Inputs and Outputs We take sepal.length, sepal.width and petal.length as an input parameter. We take petal.width as first output parameter and variety as second parameter. The […]