A blog for computer science passionates.

Wednesday 30 October 2019

Hello Friends!!!

In this article, we are going to discuss NumPy methods. In the previous article, we have learned NumPy attributes. (If you did not know different attributes of NumPy, please refer first) Now we are going to start different methods of the NumPy module.

  • numpy.arange - it returns numbers. it returns number in a sequence and defines an array of those numbers. it is equivalent to range (python in-built function).
    • Syntax: numpy.arange([start],stop,[step],dtype=None)
      • Here, start - is an optional argument. it defines start interval, the default start is 0.
      • stop - is compulsory, it is ending interval.
      • step - is also an optional parameter, it defines that with which value adjacent value is generated or increased.
      • dtype - is compulsory, but it also has the default value i.e. None. it represents data type of an array.
    • It returns ndarray object. i.e. array with type ndarray
  • Example, 
  • numpy.array - it returns an array.  
    • Syntax: numpy.array(object,dtype=None,copy=True,order='K',subok=False,ndmin=0)
      • Here, object - is a compulsory argument. in this argument, we need to pass any object that exposes an array interface.
      • dtype - is optional. it represents any desired type of array elements.
      • copy - is optional. if it is set as True, the object is copied.
      • order -is an optional argument. order maybe 'K', 'A', 'C', 'F' etc. is used to specify memory order. i.e. how elements are stored in memory. Here, K and A are unchanged and based on C and F order. C order means row-wise and F order means column-wise elements storing. default order is 'K'.
      • subok - is an optional argument. if this argument is set as True, it generates subclass array. otherwise it forced to be a base - class array. by default, it creates the base - class array.
      • ndmin - is an optional argument, describes the minimum number of dimensions of a resulting array. 
    • It returns ndarray object. 
  • Example, 
We will learn more methods in the next part of the article, through this article you can learn these two methods to create an array by using numpy.

Happy Coding...!!!☺

Wednesday 23 October 2019

Hello!!! to all CS Passionate,

In this article, we are going to learn different types of classification algorithms.
There are lots of different algorithms to solve classification problems. In which some of them are,
  1. Logistic regression
  2. Naïve Bayes classifier
  3. Nearest neighbor
  4. Support vector machine
  5. Decision tree
  6. Neural networks
  7. Random forest
And more, here in this part - 1 we are going to learn about,

Logistic Regression

Logistic regression is actually a type of regression, but it returns binary type of result so, we can use this algorithm for classification problems also, such as image is cat or not.
Logistic regression is a statistical method for regression analysis classification to conduct when the dependent variable is binary. such as pass/fail, yes/no, true/false, etc. it is a predictive analysis method like other regression methods. But we need to use logistic regression when we have a categorical target at that time we cannot use linear regression.

As it does not work linearly, it does not work for the straight line so, it performs the logistic function (the sigmoid function), as its results are between 0 and 1.
The formula for sigmoid activation function (logistic function):

1/(1+exp(-x))

(1.0)
The above formula returns a real-valued number, it returns numbers between 0 and 1.
Fig. 1.0 Logistic function (sigmoid curve). It generates output between 0 and 1.

How does Logistic regression works?

Logistic regression works on the same equation as linear regression. The linear regression equation is something like,
y^(i) = w0+w1x1(i)+w2x2(i)+...+wnxn(i)
(1.1)
The output of logistic regression σ(wTx). where σ is the logistic sigmoid function it uses the above formula (1.0). Let's assign wTx to z, so now our equation for logistic regression is σ(z). So, z = w0+w1x1(i)+w2x2(i)+...+wnxn(i) Now, to calculate logistic regression we need to work on probability. So, our equation becomes P(y(i) = 1) = 1/(1+exp(-z)).


Now, let's take an example, to predict cancer.

In the above example, we can classify cancer is 'malignant' or 'benign'. Hope you enjoy.
In the next article, we will learn about Naive Bayes Classifier. Till then learn logistic regression....☺

Tuesday 22 October 2019

Hello Friends!!!
In this article, we are going to discuss NumPy objects. In the previous article, we learned about NumPy and how to install NumPy? Now, Let's start with the NumPy module.

The main objective of the NumPy module is a homogeneous multidimensional array. All elements are of the same type, array indexed by a tuple of non - negative integer. In NumPy dimensions are called axes.

There is a class ndarray in NumPy. It works as an alias array.

The NumPy array is not the same as Python array, as python array only works with one - dimensional array.

Let's start with some attributes of ndarray object.

ndarray.ndim - it represents the number of axes of an array (here, axes is the dimension of array).
ndarray.shape - it also represents the dimension of array, but it shows tuple of integers which indicate size of different dimensions. For example (rows, cols) here, rows mean the first dimension of array and cols mean the second dimension of the array. But shape and ndim both are different attribute shape represents tuple and the length of tuple is represented by axes i.e. ndim.
ndarray.size - it represents the total number of elements of array.
ndarray.dtype - it represents the data type of elements in the array.
ndarray.itemsize - it represents the size in bytes of each element of an array.
ndarray.data - it represents the buffer containing actual elements of an array. we need not to use this attribute.

Example:


So, These are some important attributes in NumPy.

In the next article, we will learn about different methods of NumPy. All the best....👍

Thursday 17 October 2019

Hello Friends!!!
In this article, we are going to learn about the NumPy module. So, Let's staaaarrrrtttt........
Before we start you should know bit about Python.

What is NumPy?

NumPy is a python module, To work and perform numerical and some scientific calculations. Actually, the name also suggests Num (Numeric) Py (Python). It can work on N-Dimension array objects. and works powerfully with N - dim array as well as linear algebra.

It has lots' of different methods i.e. functions are available to perform lots of different numerical and mathematical operations in just a single line of code.

Why NumPy?

NumPy is a library module. Where Lists are equivalent to the array in Python, Python core library provides lists.

NumPy provides High Performance, where lists in comparison with numpy are low in the matter of performance. Some basic comparisons with Lists over NumPy:

  • NumPy occupies less memory space than lists
  • NumPy is faster than lists
  • It has lots of inbuilt operations of linear algebra.
Even NumPy works on one - dimensional as well as a multidimensional array and for any type of array it works faster with high performance.

How to Install NumPy?

Let's start with the installation of NumPy. (You need to install python first to work with NumPy)

pip install --user numpy

Here, --user becomes optional when we have opened user (user's directory in our cmd i.e. command prompt)

OR
if you are using pip3 just type
pip3 install numpy or pip3 install --user numpy

and NumPy is installed in your system. You can find more about installation on Official Site of NuPy SciPy Once Installed You can start development using NumPy.

In Next article, we will learn about NumPy functions and it's operations. Be ready...

Wednesday 16 October 2019

Hello Friends!!!

In my last article, I mentioned some important things that you need to learn for ML and DL. One of those is any programming language specially Python or R. But Python is more powerful and mostly used for ML and DL. As  it has lots of different and powerful libraries.
And today, I am going to tell you about those libraries which makes python more powerful. And one can develop ML or DL models easily by using Python.
  • NumPy - For numerical calculation
  • Pandas - For datasets
  • Matplotlib - For data visualization
  • sklearn - lot's of inbuilt algorithms and datasets
These are most important for ML. Now a days, some of them are very much popular and make easy to work and develop DL models simple and easy.
  • Tensorflow
  • Keras
  • Pytorch etc.
There are lots' of different modules and libraries in python for ML and DL. So, in my next article, we will learn about NumPy module of python.

So, be ready to learn NumPy. ☺😊

Tuesday 8 October 2019

Hello Friends!!!

Today, I am going to tell you about how to start with ML and DL. In some of my previous article, I have started ML but today I take this topic because before 6 to 8 months in one of my ML workshop some people asked me about,
How to start and what should we learn to start with ML or DL?
So, today I share this thing. here, below I mention some steps to start and what tools or things are necessary for ML.
First thing keep in mind is from any stream you belong don't worry, you can learn ML and/or DL.
  • Math
  • Statistics
  • Any one Programming Language
  • Basic SQL
All the above mentioned topics are necessary or mandatory for ML/DL. Now in all above points What should you learn?

MATH

In Math,  Linear Algebra is mandatory. in linear algebra you can start with below things.
  • scalar
  • vector
  • matrix
  • tensor
and it's operations such as, addition of matrix and matrix multiplication etc. Identity and Inverse Matrices. Even Eigendecomposition, norms, Linear Dependence and Span, Singular Value Decomposition, The Moore-Penrose Pseudoinverse etc.

STATISTICS

In Statistics, Regression and probability and Information theory are necessary. In which, random variables, probability distributions, conditional probability, chain rule, Variance and Covariance, Bayes' rule, Information Theory etc.

Any one Programming Language

Any one programming language is enough, but now a day Python or R are much popular for ML and DL, so here my suggestion is to learn Python or R but that doesn't mean java doesn't work with ML. Java has some popular libraries to work with ML but python is most used as python can work with less line of code.
for programming not only basic programming but algorithms and data structure even OOP is also necessary. So, this much in programming language.

SQL

Basic SQL i.e. queries and functions, triggers, events, procedures etc. this basic things also necessary for ML (SQL is used while working with data).

These above mentioned all the things are necessary, if you want to take dive in ML and/or DL.
After learning all the above mentioned things you can start with ML and/or DL.
So, Start from today. All the best...👍

Happy Journey for ML and DL.... 😊