Showing posts with label asaan hai. Show all posts
Showing posts with label asaan hai. Show all posts

Wednesday, April 15, 2020

Coronavirus| Data Analysis with python in easy way

Coronavirus Data Analysis with python in easy way



Hi, there hope you all are safe and doing something productive in these quarantine days.
today I am back with a very interesting topic of 2020 that is data analysis.
today we'll analyze the cases of coronavirus over the world.


Important Note                                                                          


In this tutorial I am personally using jupyter notebook in my laptop but but if you don't have that much powerful laptop or you don't know how to setup jupyter notebook no worries I already taken care of you just visit the link below a jupyter notebook hosted on google cloud opens in front of you.

 the part of exploring different features of this notebook I'll leave it on you and you can watch tutorials on youtube to speed up the learning process.


Important packages to install                                      


ok, guys, let's get back to work below python packages are very important for this tutorial if you are using jupyter notebook offline install all packages mention below but if you're using it online from the link above just install package number 2 and 3 how to do that just copy-paste below lines in the shell one by one...

1. pip install pandas                                                        
2. pip install geopandas                                                  
3. pip install descartes                                                    
4. pip install matplotlib                                                  
5. pip install request                                                       

done with this part lets move ahead......



Initialize packages                                                           


ok now lets import all the packages we had installed just type...

import pandas as pd                                                 
import geopandas as god                                         
import descartes                                                       
import matplotlib.pyplot as plt                                 
import requests                                                         

if any error occurs please let me know in the comment section with a proper screenshot then or at StackOverflow.

if no errors great job lets begin the real game...



Initializing the variables                                                  


Now, let's fetch the data of covid19 first to do that.....
we'll initialize three variables namely confirmed_cases, recovered_cases and death_cases taking fresh and updated CSV from Johns Hopkins University Github repository..... 

confirmed_cases_url = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv"

recovered_cases_url = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered_global.csv"

death_cases_url = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv"


Reading with pandas                                                        


now we will read CSV files fetched by variables vie pd.read_csv() function.
here we created three data frames namely df_confirmed, df_recovered and df_deaths...

df_confirmed = pd.read_csv(confirmed_cases_url)           
df_recovered = pd.read_csv(recovered_cases_url)             
df_deaths = pd.read_csv(death_cases_url)                          


Viewing the data                                                               


after doing this much work I am pretty much sure that you were interested in seeing how the data is stored inside these data frames so let's check it out

In python, we have three ways to see data

1. head() →  to see the first 5 rows of the table in the data frame we write...

 df_confirmed.head()                                                      


output:

coronavirus data


2. tail() →  similarly, to see the last five lines we write...

df_confirmed.tail()                                                          

output:
corona virus data


3. name →  to see entire data we use just write the data frame name...

df_confirmed                                                                   

output:
coronavirus data


Task: Try the above three things with df_recovered and df_deaths.


Additional stuff...                                                                 


ok let's explore some more cool python function commonly used in data analysis

1. suppose someone asked you whats the matrix of a particular data frame here the matrix is nothing but the number of rows and columns. we use shape function for that so we can easily find it by writing...

df_confirmed.shape                                                       

output:
            (264, 88)                                                              

2. if you were just interested in finding out how many columns or heading are there is a data frame just write...

df_confirmed.columns                                                          

output:
covd19 data


Melting the columns                                                            


now before we move ahead lets first see what melting is actually like an ice cube when it melts the water drops fell vertically on the ground in similar fashion in a table when we convert rows into columns we call it melting now clear...

ok now let's see how our table looks by typing...

df_confirmed                                                                   

output:



in the above image, you can clearly see we have four main columns in Green Province/State, Country/Region, Lat, Long, and the Red ones are just dates now the question is can't we make the fifth column which contains all these dates so data visualization become much easier the answer is yes just type...

confirm_df = df_confirmed.melt(id_vars=['Province/State','Country/Region','Lat','Long'])            

output:
covid cases

Woh! we just did it now we have all our dates in a single column with corresponding values...


Renaming                                                                            


now we have successfully melted our data but the fifth and sixth column names are not looking so good to me lets change the variable to date and value to confirmed.
we can do it by just typing... 

confirm_df.rename(columns={'variable':'Date','value':'Confirmed'},inplace=True)               
confirm.tail()                                                                       

output:
corona19 cases

take a glance at the columns we have just changed the variable to date and value to confirmed.


Joining                                                                               


isn't it is good instead of calling confirm, death recovered again and again if we can club them together in a single file and call that file to see entire data yaa it can be possible.

in the code below we will join all three data frames together inside a final_df variable to do this just type...

final_df = confirm_df.join(recovered_df["Recovered"]).join(deaths_df["Deaths"])               

output:
corona pandemic data

 see the columns we have successfully merged all three CSV files together. 



Plotting                                                                                


till now we have just seen our data in table format now its time to see it visually by just typing...

gdf01 =god.GeoDataFrame(final_df,geometry = god.points_from_xy(final_df['Long'],final_df['Lat']))
gdf01.plot(figsize=(20,10))                                   

output:
covid19 cases of world map


this plotting is not looking much appealing as we have covid19 data of world lets try to plot this data on a world map.

first, load the world map by typing the following...

world = god.read_file(god.datasets.get_path('naturalearth_lowres'))      
ax = world.plot(figsize=(20,10))                                                            
ax.axis('off')                                                                                        

output:
covid19 worldmap

now we'll plot the points on the world map we can do by typing...


fig,ax =plt.subplots(figsize=(50,20))                                                                               
gdf01.plot(cmap='Purples',ax=ax)                                                                                   
world.geometry.boundary.plot(color=None,edgecolor='k',linewidth=1,ax=ax)              
ax.axis('off')                                                                                                                      

output...
covid-19-cases-in-world


finally, we did it together this is my first blog on data visualization practical,
to get the full code visit ...

GitHub:- https://github.com/Lalitsingh5522/Covid19

let me know if you want more tutorials like this or a topic of your choice...😊  




Thanks!!! for Visiting Asaanhai or lucky5522  😀😀















Thursday, July 25, 2019

how to prepare for competitive programming


competitive programming from beginner to expert


competitive programming from beginner to expert

Hi, I guess you were a student recently came across this weird term competitive programming but don't know from where to start your programming journey so don't worry you were at right place here I will give you step by step guide to start with so let's gear up for the battlefield ......


competitive programming

competitive programming roadmap


➤ step 1: as a beginner first of all pick at least one weapon.
 here, weapon means a programming language :
choose any (C, C++, Java, Javascript, Perl, Python) or a combination of many.
      
so,         
     if you choose C then switching to C++ is easier for you.
     else if you choose java then javascript is easier for you.
     else choose python.
       
I personally prefer C++ because it is fast and the majority of the programming community uses it.
so it is easier to find a solution to a problem plus it is fastest among all languages.

➤ step 2: just learn these basic things in any of the programming language you choose...

  • use of data types
  • arrays
  • lists
  • dynamic array
  • while and for loops
  • if and else statements
  • a motivated brain
    


 step 3: go to HackerEarth navigate to basic programming and explore the platform don't worry at first you get some unknown errors and you didn't even understand the given programming problem language but with the time of 2 or 3 days, you have a fair idea what the hell is going on.

 step 4: ok if you have followed all the three steps mentioned above then you have been encountered with either of these errors.

runtime error:


➢ this error occurs if you have declared an array of size smaller then required.
to solve this take array size larger like ar[1000000]

compilation error: 


➢ the online platforms use standard compilers like GNU g++ for c and c++

➢ the java,c and c++ users  don't miss out semicolons ' ; ' or curly brackets '{}'.

➢ the lovers of python don't forget that python 2x and 3x are different so choose carefully. 

➢ c++ users don't use #include<iostream.h> insted use #include<iostream>.

time limit exceeded:


➢ it's possibly because you use an infinite while or for loop so keep an eye on what conditions you are using.

➢ the second reason may be your Internet speed is slow.

 step 5: don't forget to learn and practice the functions like...

  • sort
  • reverse
  • swap
  • gcd
  • permutation
  • binary search
  • max, min
  • pow
expert advice: to use these functions without including tons of libraries just use one i.e #include<bits/stdc++.h>
please buy a good laptop see HOW TO FIND BEST LAPTOP

 step 6: till now you get well acquainted with the HackerEarth platform now move to the data structure section and start learning different data structures and solve the problem related to them I mention the best book below which I personally prefer.


 competitive programming books I Used


 Data Structures and Algorithms:     click here


➦ Crack MNC(google/Facebook):    click here
  





➤ step 7: when you get well acquainted with the data structures go and learn different algorithms to solve problems faster.

➤ step 8: now you have passed the journey of competitive programming from beginner to expert
it's time to explorer different platform like hackerrank, CodeChef, code forces, etc and take part in different competitions like hackathons by HackerEarth and breakfast, lunch by CodeChef and earn some real money and also code vita which gives you money as well as a job.




Bonus tip:  learn data structure and algorithm well because it is the main key to master the coding competition and it is also included in your B.tec/Bca/Mca syllabus so score well in the exam as well. 

hope you like this article Feel free to comment on the topic you find difficult, be it data structure, algorithms anything tells us we will try to write an article on it in a very easy and understandable way.

If you love the post please subscribe to my Youtube Channel

Good Luck!




Wednesday, July 24, 2019

TCS CodeVita 2020 | CodeVita Season 9 Preparation

TCS Codevita 2020 | Code vita Season9 Preparation


codevita questions, what is codevita tcs, codevita 2020 questions

Codevita Season 9


For the past 7 seasons, TCS has had great fun in promoting the Programming-As-A-Sport culture. I hope you too had great fun participating in previous seasons of Codevita. Last season code vita created new milestones with over 210k students across 68 countries registering for the contest. Over 1800 CodeVitans were offered in India. The finals saw 25 top coders from 7 countries competing for the coveted title.


➨ What is TCS code vita :


you have probably heard of many programming contests like Icpc, google code jam, etc TCS code vita is also from one of those.

the TCS code vita is organized every year by tata consultancy aiming to find the best coders across the globe so that they can hire the best talent.

along with a job assist, they also give away a prize of more than $18,000 and this amount increases every year. 

Objective:


The main objective of the Codevita contest is to sharpen the contestants’ programming skills through some real-life computing practices.

The code vita contest will also

  • Help TCS spot bright students
  • Provide students an opportunity to showcase their programming talent and earn peer recognition.
  • Provide an opportunity to showcase offerings of TCS to the academic world
  • It provides a platform for students to practice and enhance their programming skills.
  • Provide exciting career opportunities for students in TCS
  • Participation certificates for students who clear the pre-qualifier round.


➧ Eligibility:


Coders from institutes across India who are completing their academic courses in 2021, 2022, 2023 and 2024 alone are eligible for this code vita contest. Registrations are invited from students in undergraduate/ postgraduate programs related to engineering/science background with any specialization. there are no percentage criteria for this examination.

 Tcs code vita Season8 results :


➨ code vita round1 results :

  • CodeVita Season9 India Round - Results have been declared on campus commune. Please login to TCS CampusCommune to check your results. 

  • CodeVita Season9 India Round - Coming soon...



 Tcs codevita registration 2021 :


  • tcs codevita registration 2021 will open on campus commune site in month of march/april so keep an eye good luck and prepare well.
  • check Registration open/closed :- click here


➧ Must Have Books :








➧ CAN also see:



➧ Codevita Season8 questions for preparation:


⇢ Tricky questions asked in codevita please refer books



                           Q & A                              

Q.  When do we get code vita round 1 interview call?

ans. first of all, let's get all participants from different zones email of selection and finally wait for the final list of ranks.


Q. When will we get the codevita result rank list?

ans. we'll email you please subscribe to our newsletter at the top right panel of the page.



Thanks!!! for Visiting Asaanhai or lucky5522  😀😀



Friday, July 19, 2019

Types of machine learning | supervised, unsupervised, semi-supervised and reinforcement


 Lesson - 2

supervised, unsupervised, semi-supervised and reinforcement learning

TYPES OF MACHINE LEARNING


types of machine learning algorithm


So as mention above we basically have four types of classification in machine learning algorithms you probably thinking that what the hack was these types so let's understand them one by one...



Supervised learning


def:: "supervised learning is when the model gets trained on the labeled dataset".

More simply we can say that in supervised learning the computer is presented with input data and their desired output data as well.
now, you may ask what that labeled data set actually is AAA okay, a label is nothing but a tag like an apple, cat, table, etc.


example 1- suppose we want to sum two numbers so instead oftelling the machine that the formula for adding two numbers is a + b. insted we give it some input data like if a=2 ,b=3 and the output is 5 and if a=4,b=5 then output is 9  so now if we ask the machine what is the output of a=2,b=5 then it automatically gives us a output based on what the machine learns from the above two sample data. if it is the desired output that is 7 then the given examples are enough but what if the answer is some other number then 7 so now its time to provide more input data to machine.

example 2- suppose you are given a basket filled with different kinds of fruits. Now the first step is to train the machine with all different fruits one by one like this:


types of machine learning in artificial intelligence



   If shape of object is rounded and depression at top having color Red then it will be labeled as –Apple.

  If shape of object is long curving cylinder having color Yellow then it will be labeled as –Banana.

Now suppose after training the model(machine), you have given a new separate fruit say Banana from basket and asked to identify it.
different types of machine learning algorithms

Since the machine has already learned the things from previous data and this time have to use it wisely. It will first classify the fruit with its shape and color and would confirm the fruit name as BANANA and put it in Banana category. Thus the machine learns the things from training data(basket containing fruits) and then apply the knowledge to test data(new fruit).


I guess now you get a fair idea what this supervise learning thing is OK buddies its time to explorer the subparts of supervised learning lets understand them too...

Supervised learning is classified into two categories of algorithms
:

1.Classification:
4 types of machine learning algorithms

"A classification model predicts discrete values"                              OR                          
More easily we can say that a classification problem is when the output variable is a category, such as “Red” or “blue” or “disease” and “no disease”.                                           
For example, classification models make predictions that answer questions like the following:                
➤ Is a given email message spam or not spam?          
➤ Is this an image of a dog, a cat, or a hamster?                                                                                                                                               
2.Regression:
supervise learning
  "A regression model predicts continuous values"                   OR                             
A Regression problem is when the output variable is a real value, such as “dollars” or “weight”.
For example, regression models make predictions that answer questions like the following:
➤ What is the value of a house in California?
➤ What is the probability that a user will click on this ad?



okay, now I am pretty much sure that your doubts about supervise learning get resolved if not you can always ask in the comment section.

ooh I got this you do not get the full understanding of regression and classification plus the diagram provided makes the situation even worse. 
don't worry about those confusing diagrams we'll cover them in detail in a separate article.

let's move on to the next section that is unsupervised learning.


Unsupervised learning:



def:: "unsupervised learning is when no labels are given to the learning algorithm, leaving it on its own to find structure in its input".

pretty difficult huh.. let's make it simple okay so unlike supervised learning,  in unsupervised learning there is no prior training provided to the algorithm, therefore, the machine is restricted to find hidden patterns in the unlabeled data.
this means here we don't tell the machine that this is an apple or banana
the machine should figure it out on its own. 


example 1: suppose we have an image having cats and dogs both but the machine never seen it before now the twist here is that in supervise learning we train the algorithm how cat is different from dog but in unsupervised learning we do not give the algorithm any prior training  in addition ask the algorithm to classify them based on its own understanding


unsupervise learning
thus the machine have no idea about the features of dogs and cats so it can't categories them with labels like dogs and cats but but but it can categories them based on their similarity's and differences like dogs have long tongue cats have small, dogs are longer cats are shorter and you may make many more differences but how machines do that we'll get back to its technical details in our next articles

it's interesting to know how supervise and unsupervised learning are completely opposite brothers.
OK let's not waste any more time and explore the roots of machine learnings second brother that is unsupervised learning.

now here in unsupervised learning we again have two categories:


  1.  clustering:

    clustering in unsupervised learning
    clustering means making different groups as we know we can't classify objects in unsupervised learning but to do so we can make clusters(groups) of the same feature objects.                                                                                                                                                                                  
  2. Association: in association the machine tries to relate two or more things based on some rules, such as people that buy X also tend to buy Y live example is YouTube for example when you watch the funny video it recommends you other funny videos.



so far we have covered the two major topics of machine learning now its time to cover the two remaining one that are-


Semi-supervised learning


 when a large amount of data is given in which some data is labeled and some data is not labeled then it is called semi-supervised learning so we can say it is the half half version of supervised and unsupervised learning.


example: suppose you were given a basket of fruits some have labels like apple,banana etc but some are unlabeled  so semi-supervised learning basically deals with such type of data.


Finally, we have our last topic lets talk about it :


Reinforcement learning


reinforcement learning is the real challenge in machine learning here the machine deal with the dynamic environment that is in the game of chess machines needs to take decision based on opponents moves or machine needs to play a shooting game like pubg on its on without human help so this is called reinforcement learning in this we try to implement our all understanding of machine learning.

don't worry we'll end this course with implementation of all our learning.


BOOKS FOR MACHINE LEARNING:


these are the books which I personally prefer hope you like the way of teaching too...

  • A Guide To Data science

  • Introduction To Machine Learning


Youtube Channel:

need the support of you guys - link to youtube


That's all for today hope you're liking my efforts keep enjoying and keep learning 

😃😃😃













Everything Need To Know About BATTLEGROUNDS MOBILE INDIA

 BATTLEGROUNDS MOBILE INDIA  Finally, Krafton unveiled India’s beloved battle-royale game PUBG Mobile, but with a new name – Battlegrounds M...