Reading Time: 2 minutes

The corona pandemic has claimed many lives across the world. It’s other side effects include the widespread rampage on all sectors of economy of the world. It has caused the closure of many small industries, businesses and enterprises and it continues to haunt the future of  not only SMEs(Small and Medium Enterprises), MSMEs (Micro Small Medium Enterprises), Microfinance Institutions but also big companies.


In view of this, big Chinese banks, Private Equities and other multilateral instruments are investing heavily in such falling companies. These Chinese corporations work under the beneficial owner; the government of China. China’s recent increase in investment in HDFC bank has exceeded 1% which has poked the bear (RBI) into looking into this matter.



The problem is that by investing heavily they are buying shares of these companies at “THROWAWAY PRICES”. The impact of this, is that they will be majority stakeholders of these companies or aim to attempt buying them eventually (“HOSTILE TAKEOVER”). This will give them power to control these businesses and help them direct profit money to China.


China currently invests around $4 billion in Indian startups.18 out of 30 Indian unicorns (startups  having more than $1 billion market capitalization)  have Chinese funding.Big investors from China -Alibaba, Tencent , ByteDance have made huge investments in Paytm, Byju’s , OYO, Ola, Big Basket, Swiggy, Zomato. China dominates Indian markets in pharmaceutical APIs(Active Pharmaceutical Ingredients), mobile phone markets, automobiles and electronic and project imports.





The  Government of India and RBI (Reserve Bank of India) lost no time in rectifying it’s policies.The government has decided to screen Foreign Direct Investments (FDI) from countries sharing a land border with India or where the beneficial owner of an investment into India is situated in or is a citizen of any such country. The capital market regulator of India ,SEBI (Securities Exchange Board of India) is also digging deeper into  Foreign Portfolio Investors(FPI) composition from China, by seeking beneficiary details from jurisdictions like Mongolia, Bhutan, Nepal, Bangladesh , Afghanistan and Yemen.



These policy changes have put an end to such hostile takeovers yet other measures need to be taken in order to mitigate China’s sway over the market.


Getting Started with Machine Learning with Python

Reading Time: 9 minutes



In my previous tutorial Constructing a Simple Blockchain using PYTHON , I did promise on writing the further about Applications of Blockchain & their Implementation. I will soon post regarding the same. I wanted to make the next tutorial over Blockchain as simple as possible, so I will be needing some time to design my next Tutorial blog on Blockchain. So, keep patience :).

Now, alongside me learning the blockchain, I was also working on Machine Learning and Deep Learning, as if it is my core Learning subjects.

In my last blog on Blockchain, I received few comments that the terms were not easy to understand, thus making the blog difficult to read for the readers completely new to programming, which, is of course very true because these technologies have their own glossary.

I came up with an idea to give you guys the taste of the Machine Learning Models with the easiest way possible, to make my blog better, or you can say that I just trained myself ; P.

Getting Started with Machine Learning with Python

Machine Learning

“Machine learning is a field of computer science that uses statistical techniques to give computer systems the ability to “learn” with data, without being explicitly programmed.”

Does that help?

I guess not!

My belief for doing the things perfectly is by actually doing them.

I would love to dip my hands into something worthy rather than sitting and listening to some boring lectures (though they are not that boring, it’s my way of understanding things 😀 ;p).

So, here I present you the best way, that I think is well enough to get you guys a boost start in making and understanding machine learning models.

Getting Started

Before actually getting started, let’s get back to the definition and try to understand it,

“Machine learning is a field of computer science that uses statistical techniques to give computer systems the ability to “learn” with data, without being explicitly programmed.”

Few words to underline:


-ability to “learn”

-without being explicitly programmed

Now in this tutorial, I will not be taking the names of any technical term except the ones that you need to know. Or better to say the ones which are extremely required. Because I think, for those who are having their first experience in Machine Learning, it becomes extremely confusing when such “Out of their Glossary” kind of terms starts bombarding on them.

So, now how can we start understanding above-underlined terms? How do we actually implement them? How a machine with zero IQ will learn? How will it answer to the problems that are new to them? And most importantly how will we train the machine?

I will try to explain it in very short as I can.

->Statistical means you have previously recorded data of Thousands or millions or even billions of records. E.g. the data of

  • Occurrences of words in emails marked as SPAM
  • Data of various houses & their degree of damage along with structural information of the houses etc.

These datasets are used to make a Mathematical Model, which will then be used to predict the answers for the test datasets.

->Ability to “learn” here is not that computer gets some human power or something and starts learning on its own. Naah. This the thing which we recently called the Mathematical Model.

We actually create a mathematical model using the previous datasets and train them on basis of them, or in other words to say we actually plot them using various techniques (in fancy words called as Machine Learning Algorithms ) based on features (another fancy term), which actually stands for various properties or information related to some object in which we are going to predict our results on.


  • Linear Regression
  • Logistic Regression
  • Decision tree Classifier
  • Random Forest
  • Neural Networks etc. etc. etc.

😀 Haha.. none of them gives us clue what they mean. Right?

Now before moving forward I would love to illustrate you with some example, you’ll love the way it all works:

Suppose you want to distinguish between an “apple” and an “orange”.

Getting Started with Machine Learning with Python

Now what you have for information about them?

Ummm, maybe weight, or color may be different levels of its ripeness as it may be possible that apple or orange may have different weights and color at different ripeness level.

Isn’t it?

“Now, we have two features color and weight now.”

A mathematical model is created by plotting these properties on a 2d graph as shown. But that is possible if we have some numerical representation of a feature.

Getting Started with Machine Learning with Python

In this way, we plot them(intuitively), and ready to classify them.

So for the training data we will plot new inputs on this graph and the examples plotted on this graph having ordinates > line will be oranges and the ones having ordinates <line, are the apples.

This is an example of simple Linear regression, in which we plot a line to classify between two targets.

And this is how a computer performs without being explicitly programmed.

Why Python?

PYTHON being the most famous language of today, besides another like JAVASCRIPT, is extremely simple, ridiculously fast, and has a huge Library for various uses ranging from COMPUTATIONAL UTILITIES to CREATING A P2P network.

It may happen that you want to do Machine Learning, and you don’t need to take a full course on python. I know many of the sources where you can learn enough python to go on with machine learning.

Getting Started with Machine Learning with Python

Starting with Building a Machine Learning model.

Steps : –

    1. Installing required Libraries
      Pandas, scikit learn, numpy… that’s it for now
    2. Creating python file, importing required libraries and all
    3. Loading dataset
      we can do with any library but for now, we’ll just have Iris flower dataset, which is actually considered as “Hello world” dataset for python, you’ll find at many places
    4. Exploring our dataset
    5. Making our first model
    6. Printing the accuracy of our model
    7. Testing various models

**Note: Before starting anything I need you to clone the following repo from GitHub link to your local PC:

1. Installing required Libraries

In the Github repo given above, you’ll find a file name required.txt, this file has all the requirements for the project, just run the following command into your terminal, being into repo directory to install required packages.

sudo apt-get -y install python3-pip
pip3 install -r required.txt

This will install all the required libraries for our model.

2. Creating a Python file, importing libraries and all

Create a python file of your desired name with .py extension in the repo directory, and open it into your favourite text editor and import required libraries as follows:

import pandas as pd
from sklearn import model_selection
from sklearn.metrics import accuracy_score
# these are various machine learning models already stored in the sklearn library
from sklearn.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
from sklearn.naive_bayes import GaussianNB
from sklearn.svm import SVC


3. Loading the Dataset

Here we shall use read_csv() function of pandas library to read our dataset as follows.

file = pd.read_csv("", header = None)

file.head(5) will view the first 5 rows of the dataset.

And do notice, in read_csv we have header = None, this is used because our dataset does not contain any headings to define the columns. It will look something like this:

Getting Started with Machine Learning with Python

4. Exploring our dataset

Few things before building our model.

Run the following lines to print various information about the dataset we are going to use.

  1. Finding dimensions

 2. Describing data with analytics


3. Printing distribution of class(grouping according to column no 4, as we have seen in point 3.)



5. Making our First model

Before making any Model and testing data on it, we have a very important step, that is to creating training & testing datasets separately. To train the model on and to test the model on.

For this purpose, we have already imported model_selection  from sklearn.

->  Splitting dataset into Training and Testing

Following code is to first change the dataset into a 2D array, then separating the target from it into Y, defining seed. And finally dividing our dataset into training and validation dataset.

array = file.values     # dataset to a 2d array
X = array[:,0:4]        # feature dataset
Y = array[:,4]          # target dataset
# validation size is used to take out 0.3 i.e 30% of our dataset into test dataset.
validation_size = 0.30
seed = 5                # why random seed is used its given
# finally slicing our dataset into training and testing
X_train, X_validation, Y_train, Y_validation = model_selection.train_test_split(X, Y, test_size=validation_size, random_state=seed)
# to test if its sliced properly

-> Defining and using our model

We will be using simple Logistic Regression classifier as our model and use to train our dataset and predict the outcomes.

Few steps, Define model, then fit model, then predict the output.

model = LogisticRegression()
# fitting our model, Y_train)
# predicting outcomes
predictions = model.predict(X_validation)


print(predictions[:10])) will print the predictions on validation dataset after being train on the training dataset.

6. Printing the accuracy of our model

Now to rate our model we need to find its accuracy. For this, we need to compare our Validation data to our predicted data. And since we are using a library we don’t need to manually calculate it.  We have the following command to do this job as we have already imported accuracy_score from sklearn.metrics.

print(accuracy_score(Y_validation, predictions))


I had the following output when I ran this in my ipython notebook, which I have included in my Github repo.

Getting Started with Machine Learning with Python

It is 93.33% accurate.

And now, you are done with your first machine learning model.

7. Testing Various models

model = LogisticRegression(), Y_train)
predictions = model.predict(X_validation)
print("Logistic Regression: ", accuracy_score(Y_validation, predictions, "\n"))
model = DecisionTreeClassifier(), Y_train)
predictions = model.predict(X_validation)
print("DecisionTreeClassifier: ", accuracy_score(Y_validation, predictions, "\n"))
model = KNeighborsClassifier(), Y_train)
predictions = model.predict(X_validation)
print("KNeigbhorsClassifier: ", accuracy_score(Y_validation, predictions, "\n"))
model = SVC(), Y_train)
predictions = model.predict(X_validation)
print("SVC: ", accuracy_score(Y_validation, predictions, "\n"))
model = LinearDiscriminantAnalysis(), Y_train)
predictions = model.predict(X_validation)
print("LinearDiscriminantAnalysis: ", accuracy_score(Y_validation, predictions, "\n"))
model = GaussianNB(), Y_train)
predictions = model.predict(X_validation)
print("GaussianNB: ", accuracy_score(Y_validation, predictions, "\n"))


My Output was as Follows:

Getting Started with Machine Learning with Python

Here are various accuracies of different models, we will be learning about in upcoming blogs.

**Please have a look at the ipython nb in the repository. Also, you can comment in the REPOSITORY itself.

So, that’s it with this tutorial blog.

My next blog on Machine Learning will be quite boring as I will be explaining some “Boring” terms of machine learning. And after reading this blog. You’ll have an easy understanding of those terms. And also An intuitive idea of every term if you want to learn good quality machine learning.

***Note. If you want then I’ll be providing some references about it in the blog.

# Please provide your suggestions and even if there’s any doubt regarding whatever you have learned from this blog or any other blog. Just get in touch with me @ my email

Or comment it on our FB page or insta page.

Happy Learning!


Constructing a Simple Blockchain using PYTHON

Reading Time: 6 minutes

– by Aman Pandey


What does the path consist?

The goal of this article is to let you know about a BASIC BLOCKCHAIN structure by making a sample blockchain by using a Scripting language Python.

And a small assignment at the last.

The information about the following will be provided on the further articles:

    • various applications of blockchain and at various levels
    • use blockchain to create your own cryptocurrency
    • use of blockchain to create a file deployment system

and Many More…

This article will, for right now, will not have information about deploying your own Blockchain Application, and creating a distributed and decentralized file sharing system.

If you are just interested with how to create a blockchain Jump directly to CONSTRUCTING even I would have done that…

So, let’s start to learn something new……

What is Blockchain?

Back in 2008, some mysterious Person/group of persons named SATOSHI NAKAMOTO released a whitepaper  named Bitcoin: A Peer to Peer Electronics Cash System (I suggest that you read the paper to understand how it was presented to the world) in which BITCOIN was described to be a BLOCKCHAIN based technology,

    • a completely trustless (though the meaning is exactly the opposite, it actually means no trust issues)
    • Distributed
    • Decentralised
    • and, Encrypted

technology that can actually serve as a new form of currency which has its value just as a Stock Share and transaction just like a Barter system.

So, right now before turning this article into a History(story) or market revolutionalizing technology journey let’s start some keyboard ticking and see where we are able to implement key points of a Blockchain, though I will provide you enough resources to read more about emergence and have an intuitive idea about its potential.

Let’s get started…

Design and Features

So, let us begin with the basic design of blockchain by understanding how does it implement its key features.

Before explaining further I want you to go through this wonderful video about blockchain. So we shall jump directly to the technical part. It will let you understand most of the things.

Now after this you must have understood the basic structure of Blockchain.

It is a distributed and decentralized ledger system which provides a TAMPER free service to store records.

Constructing a Simple Blockchain using PYTHON

Image Source:


Constructing a Simple Blockchain using PYTHON


    • Python 3.6 (a basic python would work but if you don’t know any about it don’t worry it’s very simple and I will try to give an intuitive idea about what I am using and why.)
    • a cool text editor would work well
      > Sublime Text 3 (choose according to the platform you have, it’s lightweight and good)n
      > Atom (the best one to use, has an extension for a terminal)
    • LINUX (Suggested, It’s better to switch to Linux now if you really have to do some good)

                                                                                                                                                          ……that’s it for now, its basic

Let us start by creating a BLOCK:

-> BLOCK:-

We’ll start by creating a class of simple BLOCK using Python:

Constructing a Simple Blockchain using PYTHON

class block:
      def __init__ (self, timestamp, data, previousHash = ' '):
         self.timestamp = timestamp = data
         self.previousHash = previousHash
         self.hash = #TODO function calculateHash()

Just have a look at this block we have 4 arguments. Of course, self is working for self-element initialization, for those who don’t understand just understand that it is a kind of PYTHON convention of constructors.

Also that we haven’t included hash in the block argument as it will be calculated and stored inside the function itself #TODO.

Now let’s write the function to calculate hash the block:

def calculateHash(self):
    return sha256((str(self.timestamp) + str( + \

Now, few points to note here are

    • use of encode() and in the return line hexdigest()
      → so the answer for that is you need to encode every text before hashing, I’ll try to cover it in further blogs.
      → and to convert hash object into a string  we need to use the hexdigest function
    • and yes, for sha256 you need to import hashlib library, and also you need to convert everything into a string before hashing it
  • Also, we need to include time for timestamp

So the code for blocks looks like: –

from hashlib import sha256
import time
class block:
      def __init__ (self, timestamp, data, previousHash = ' '):
         self.timestamp = timestamp = data
         self.previousHash = previousHash
         self.hash = # TODO
      def calculateHash(self):
         return sha256((str(self.timestamp) + str( + \ str(self.previousHash).encode()).hexdigest())

and now let’s begin with our Blockchain class definition:


Genesis Block: the very first block of the blockchain is termed as a genesis block. And it generally can have any data. So we need to initialize our blockchain with it if we don’t have any block in the BLOCKCHAIN. We will have the following structure:

Data → “genesisBlock”

previousHash → “00000”

class blockchain:
      def __init__(self):
         self.chain = [self.createGenesis()]
      def createGenesis(self):
         return block(time.ctime(), "genesisBlock", "00000")

So this is our blockchain which gets initialized with a list named chain, everytime a new class object is created. We’re still having some functions to add to it.


Whenever a new transaction is made, and a new block is created and added to the blockchain, the complete process is termed as mining.

As to make blockchain simple for this very first blog, I am not going to put any complex mining functions and verification algorithms for now. Just deal with simple mining.

So, the mining functions will be having to take input from the user and create a block/node for it.

So, before making mining, we have to deal with taking the user’s input and start mining:

  • Starting a Blockchain
  • CEVcoin = blockchain()
  • Taking user input and creating a block
  • data = input()
  • Writing mineBlock():

This function is the part of the blockchain so has to be written inside blockchain. Hence our code  with the function of adding nodes looks like:

from hashlib import sha256
import time
class block:
  def __init__ (self, timestamp, data, previousHash = ' '):
    self.timestamp = timestamp = data
    self.previousHash = previousHash
    self.hash = self.calculateHash()
  def calculateHash(self):
    return sha256((str(self.timestamp) + str( + str(self.previousHash).encode()).hexdigest())
class blockchain:
  def __init__(self):
    self.chain = [self.createGenesis()]
  def createGenesis(self):
    return block(time.ctime(), "genesisBlock", "00000")
  def mineBlock(self, data):
    node = block(time.ctime(), data, self.chain[-1].hash)
    # mining a new block to the blockchain
CEVcoin = blockchain()
data = input()
# sending data to get mined
print(“\n\nMining new block……..”)

*do note down the self.calculateHash() application in def __init__ function of block

Well, this the BACKBONE of every BLOCKCHAIN.

Its applications are at many places. Bitcoin is one of them. Refer links at the bottom for them.

One last thing I’ll do is to print the Blockchain we just made:

def printBlockchain(self):
    for i in range(len(self.chain)):
      print("\n-----Block ", i ,"---------\n timestamp = "\
            , self.chain[i].timestamp,"\n data = ", \
             self.chain[i].data, "\n previousHash = ",\
               self.chain[i].previousHash,"\n hash = ", \

Just add it inside the class blockchain().

And here, you are done with your first blockchain cryptocurrency

For complete CODE refer :

*i’ll add more blogs with its applications like

  • Making a ledger system
  • Making your own cryptocurrency
  • Regarding P2P network based blockchain

**Please do like & share this blog if you really like it. And comment if any doubts.

Blog by:

Aman Pandey

2nd Year, Civil Engineering, SVNIT.

You can also have a look at my team Project with Ujjwal Kumar – LinkedIn & Hrishabh Sharma – LinkedIn, another CEV members @ Rajasthan DIGIFEST 2k18 Online hackathon – a 36 hours hackathon held on 6 July 2018 on making a cryptocurrency RAJCOIN for Rajasthan Govt @ the following Github link.

You need to follow the complete instructions given in readme. SO, KEEP PATIENCE.

Extra Resources to read:


Now the assignment is that, make your own crypto coin and mail the code as a zip file to my email id

**you can ask any doubts regarding this @ the email address provided above.

Please give a thumbs up and share if you really like the blog.

NOTE: this is only for Educational purposes and not for commercialization.


CEV - Handout