Wednesday, July 29, 2020

Subjects and variables

Defining subjects and variables: Quantitative (discrete, continuous) vs Categorical (ordinal, nominal)


If you look at the mpg dataset, you'll notice a standard way of representing data in R and most standard statistical packages. Each row is a subject, and each column is a variable.

Table of MPG dataset

Subject means the smallest object or entity that you measure. In the mpg dataset, this is types of cars, and each row is a different type of car.

The things that you measure are called variables. So for the first car, the manufacturer is Audi and the model is a4. You refer to the manufacturer and model as variables. In statistics, variables are classified into four main types:

  • categorical ordinal,
  • categorical nominal,
  • quantitative continuous, and
  • quantitative discrete.

Categorical variables are things that can be classified with labels. Categorical ordinal are labels that have an order, for example the bronze, silver and gold medals in the Olympics, while categorical nominal are labels that do not have an order. In the mpg dataset, manufacturer is a categorical nominal variable, while model may be a categorical ordinal as models are often ordered according to price.

Quantitative variables are things that are measured using numbers. Quantitative continuous variables can take any numerical value, including fractions and decimals. For example: time, temperature, length and weight, and anything that is derived from them. On the other hand, quantitative discrete variables are things that are counted, so only take whole-number values. For example you may count the number of people infected with a disease, or the number of cars that cross a bridge.

The main difference is that a sufficiently accurate measuring device can measure quantitative continuous random variable to any value in a range, while discrete will always have gaps between the numbers, for example you can’t have 3.5 people infected with a disease.

In the mpg dataset, the variable cyl stands for the number of cylinders in the car. As cylinders are countable (rather than measured continuously), this variable is a quantitative discrete variable. The variable displ stands for an engine's displacement, which is a volume (in litres). Therefore, being something that is measured, it is a quantitative continuous variable.

Notice that as displacement is measured to the nearest 0.1 of a litre, this variable ends up being discretised. However, it is still considered to be a continuous variable, as theoretically, volume could be recorded to any number of decimal places. On the other hand, you can never have half a cylinder, so the cyl variable will always be quantitative discrete.

So why do we care about this? Because if we know the type of variable, then we know how to deal with it statistically.



Introduction to Dataframes in R

Looking at dataframes in R

Dataframes are the fundamental data structure in R. They are essentially tables consisting of variables and observations. If you can represent your dataset as a dataframe, you're ready to start answering questions about it using the power of R. Let's take a look at a dataframe.

Load the mpg dataframe contained in the tidyverse package:

library(tidyverse)
mpg

## # A tibble: 234 x 11
##    manufacturer      model displ  year   cyl      trans   drv   cty   hwy
##           <chr>      <chr> <dbl> <int> <int>      <chr> <chr> <int> <int>
##  1         audi         a4   1.8  1999     4   auto(l5)     f    18    29
##  2         audi         a4   1.8  1999     4 manual(m5)     f    21    29
##  3         audi         a4   2.0  2008     4 manual(m6)     f    20    31
##  4         audi         a4   2.0  2008     4   auto(av)     f    21    30
##  5         audi         a4   2.8  1999     6   auto(l5)     f    16    26
##  6         audi         a4   2.8  1999     6 manual(m5)     f    18    26
##  7         audi         a4   3.1  2008     6   auto(av)     f    18    27
##  8         audi a4 quattro   1.8  1999     4 manual(m5)     4    18    26
##  9         audi a4 quattro   1.8  1999     4   auto(l5)     4    16    25
## 10         audi a4 quattro   2.0  2008     4 manual(m6)     4    20    28
## # ... with 224 more rows, and 2 more variables: fl <chr>, class <chr>


Look at all that data! This dataframe contains data about the fuel economy of cars, collected between 1999 and 2008. Specifically, it's a table containing 234 rows, and 11 columns. It's called a "tibble", which is just a slightly modernised version of R's original data.frame. We'll come back to the mpg dataset in Subjects and Variables.

You can create your own tibbles:

mytibble <- tibble(
  x = 1:4, 
  y = x^2, 
  z = y + 0.1
)
mytibble
## # A tibble: 4 x 3
##       x     y     z
##   <int> <dbl> <dbl>
## 1     1     1   1.1
## 2     2     4   4.1
## 3     3     9   9.1
## 4     4    16  16.1

And also create "tribbles": not the troublesome kind of Tribbles, but "transposed tibbles":

mytribble <- tribble(
  ~x, ~y, ~z,
  1, 4.2,"a",
  3, 9.6,"b",
  4,16.8,"c"  
)
mytribble
## # A tibble: 3 x 3
##       x     y     z
##   <dbl> <dbl> <chr>
## 1     1   4.2     a
## 2     3   9.6     b
## 3     4  16.8     c

...which might be easier, depending on your situation.

Great! So, if you have done what I have been showing you here, you should now be able to load dataframes, and even build your own dataframes!

Getting variables from a dataframe

You might want to look at only part of a dataframe. For example, I noticed the names of a number of models of cars in the mpg dataset, so let's focus in on them. You can select a single column using the $ symbol:

mpg$model
##   [1] "a4"                     "a4"                    
##   [3] "a4"                     "a4"                    
##   [5] "a4"                     "a4"                    
##   [7] "a4"                     "a4 quattro"            
##   [9] "a4 quattro"             "a4 quattro"            
##  [11] "a4 quattro"             "a4 quattro"            
##  [13] "a4 quattro"             "a4 quattro"            
##  [15] "a4 quattro"             "a6 quattro"            
##  [17] "a6 quattro"             "a6 quattro"            
##  [19] "c1500 suburban 2wd"     "c1500 suburban 2wd"    
##  [21] "c1500 suburban 2wd"     "c1500 suburban 2wd"    
##  [23] "c1500 suburban 2wd"     "corvette"              
##  [25] "corvette"               "corvette"              
##  [27] "corvette"               "corvette"              
##  [29] "k1500 tahoe 4wd"        "k1500 tahoe 4wd"       
##  [31] "k1500 tahoe 4wd"        "k1500 tahoe 4wd"       
##  [33] "malibu"                 "malibu"                
##  [35] "malibu"                 "malibu"                
##  [37] "malibu"                 "caravan 2wd"           
##  [39] "caravan 2wd"            "caravan 2wd"           
##  [41] "caravan 2wd"            "caravan 2wd"           
##  [43] "caravan 2wd"            "caravan 2wd"           
##  [45] "caravan 2wd"            "caravan 2wd"           
##  [47] "caravan 2wd"            "caravan 2wd"           
##  [49] "dakota pickup 4wd"      "dakota pickup 4wd"     
##  [51] "dakota pickup 4wd"      "dakota pickup 4wd"     
##  [53] "dakota pickup 4wd"      "dakota pickup 4wd"     
##  [55] "dakota pickup 4wd"      "dakota pickup 4wd"     
##  [57] "dakota pickup 4wd"      "durango 4wd"           
##  [59] "durango 4wd"            "durango 4wd"           
##  [61] "durango 4wd"            "durango 4wd"           
##  [63] "durango 4wd"            "durango 4wd"           
##  [65] "ram 1500 pickup 4wd"    "ram 1500 pickup 4wd"   
##  [67] "ram 1500 pickup 4wd"    "ram 1500 pickup 4wd"   
##  [69] "ram 1500 pickup 4wd"    "ram 1500 pickup 4wd"   
##  [71] "ram 1500 pickup 4wd"    "ram 1500 pickup 4wd"   
##  [73] "ram 1500 pickup 4wd"    "ram 1500 pickup 4wd"   
##  [75] "expedition 2wd"         "expedition 2wd"        
##  [77] "expedition 2wd"         "explorer 4wd"          
##  [79] "explorer 4wd"           "explorer 4wd"          
##  [81] "explorer 4wd"           "explorer 4wd"          
##  [83] "explorer 4wd"           "f150 pickup 4wd"       
##  [85] "f150 pickup 4wd"        "f150 pickup 4wd"       
##  [87] "f150 pickup 4wd"        "f150 pickup 4wd"       
##  [89] "f150 pickup 4wd"        "f150 pickup 4wd"       
##  [91] "mustang"                "mustang"               
##  [93] "mustang"                "mustang"               
##  [95] "mustang"                "mustang"               
##  [97] "mustang"                "mustang"               
##  [99] "mustang"                "civic"                 
## [101] "civic"                  "civic"                 
## [103] "civic"                  "civic"                 
## [105] "civic"                  "civic"                 
## [107] "civic"                  "civic"                 
## [109] "sonata"                 "sonata"                
## [111] "sonata"                 "sonata"                
## [113] "sonata"                 "sonata"                
## [115] "sonata"                 "tiburon"               
## [117] "tiburon"                "tiburon"               
## [119] "tiburon"                "tiburon"               
## [121] "tiburon"                "tiburon"               
## [123] "grand cherokee 4wd"     "grand cherokee 4wd"    
## [125] "grand cherokee 4wd"     "grand cherokee 4wd"    
## [127] "grand cherokee 4wd"     "grand cherokee 4wd"    
## [129] "grand cherokee 4wd"     "grand cherokee 4wd"    
## [131] "range rover"            "range rover"           
## [133] "range rover"            "range rover"           
## [135] "navigator 2wd"          "navigator 2wd"         
## [137] "navigator 2wd"          "mountaineer 4wd"       
## [139] "mountaineer 4wd"        "mountaineer 4wd"       
## [141] "mountaineer 4wd"        "altima"                
## [143] "altima"                 "altima"                
## [145] "altima"                 "altima"                
## [147] "altima"                 "maxima"                
## [149] "maxima"                 "maxima"                
## [151] "pathfinder 4wd"         "pathfinder 4wd"        
## [153] "pathfinder 4wd"         "pathfinder 4wd"        
## [155] "grand prix"             "grand prix"            
## [157] "grand prix"             "grand prix"            
## [159] "grand prix"             "forester awd"          
## [161] "forester awd"           "forester awd"          
## [163] "forester awd"           "forester awd"          
## [165] "forester awd"           "impreza awd"           
## [167] "impreza awd"            "impreza awd"           
## [169] "impreza awd"            "impreza awd"           
## [171] "impreza awd"            "impreza awd"           
## [173] "impreza awd"            "4runner 4wd"           
## [175] "4runner 4wd"            "4runner 4wd"           
## [177] "4runner 4wd"            "4runner 4wd"           
## [179] "4runner 4wd"            "camry"                 
## [181] "camry"                  "camry"                 
## [183] "camry"                  "camry"                 
## [185] "camry"                  "camry"                 
## [187] "camry solara"           "camry solara"          
## [189] "camry solara"           "camry solara"          
## [191] "camry solara"           "camry solara"          
## [193] "camry solara"           "corolla"               
## [195] "corolla"                "corolla"               
## [197] "corolla"                "corolla"               
## [199] "land cruiser wagon 4wd" "land cruiser wagon 4wd"
## [201] "toyota tacoma 4wd"      "toyota tacoma 4wd"     
## [203] "toyota tacoma 4wd"      "toyota tacoma 4wd"     
## [205] "toyota tacoma 4wd"      "toyota tacoma 4wd"     
## [207] "toyota tacoma 4wd"      "gti"                   
## [209] "gti"                    "gti"                   
## [211] "gti"                    "gti"                   
## [213] "jetta"                  "jetta"                 
## [215] "jetta"                  "jetta"                 
## [217] "jetta"                  "jetta"                 
## [219] "jetta"                  "jetta"                 
## [221] "jetta"                  "new beetle"            
## [223] "new beetle"             "new beetle"            
## [225] "new beetle"             "new beetle"            
## [227] "new beetle"             "passat"                
## [229] "passat"                 "passat"                
## [231] "passat"                 "passat"                
## [233] "passat"                 "passat"

Do you notice how when you type mpg$, a list of the column names pops up? You can navigate this list using the arrow keys, or even start typing part of a column name to search the list. For example, as the model column is the only column of mpg containing an "o", I could have typed mpg$, then o, then hit enter, and ended up with the same as above. Neat!

Note: You can get the same result as above by typing mpg[['model']], but you don't get the auto-complete in RStudio compared to the first version.

Anyway, that was a lot of car model names (234 to be precise - the same as the number of rows of the dataframe). What if we want to see how many different types of car there are in the dataset? Let's try putting the word unique in front of our previous command...

unique(mpg$model)
##  [1] "a4"                     "a4 quattro"            
##  [3] "a6 quattro"             "c1500 suburban 2wd"    
##  [5] "corvette"               "k1500 tahoe 4wd"       
##  [7] "malibu"                 "caravan 2wd"           
##  [9] "dakota pickup 4wd"      "durango 4wd"           
## [11] "ram 1500 pickup 4wd"    "expedition 2wd"        
## [13] "explorer 4wd"           "f150 pickup 4wd"       
## [15] "mustang"                "civic"                 
## [17] "sonata"                 "tiburon"               
## [19] "grand cherokee 4wd"     "range rover"           
## [21] "navigator 2wd"          "mountaineer 4wd"       
## [23] "altima"                 "maxima"                
## [25] "pathfinder 4wd"         "grand prix"            
## [27] "forester awd"           "impreza awd"           
## [29] "4runner 4wd"            "camry"                 
## [31] "camry solara"           "corolla"               
## [33] "land cruiser wagon 4wd" "toyota tacoma 4wd"     
## [35] "gti"                    "jetta"                 
## [37] "new beetle"             "passat"

It works! There are 38 different types of cars in the dataset.

If you want to select rows rather than columns from the dataframe, use square brackets [], for example:

mpg[194,]
## # A tibble: 1 x 11
##   manufacturer   model displ  year   cyl    trans   drv   cty   hwy    fl
##          <chr>   <chr> <dbl> <int> <int>    <chr> <chr> <int> <int> <chr>
## 1       toyota corolla   1.8  1999     4 auto(l3)     f    24    30     r
## # ... with 1 more variables: class <chr>

If you want a particular entry in the dataframe, provide a column number as well:

mpg[194,2]
## # A tibble: 1 x 1
##     model
##     <chr>
## 1 corolla

And, of course, you can also look at a range of rows and columns as well:

mpg[194:198,1:4]
## # A tibble: 5 x 4
##   manufacturer   model displ  year
##          <chr>   <chr> <dbl> <int>
## 1       toyota corolla   1.8  1999
## 2       toyota corolla   1.8  1999
## 3       toyota corolla   1.8  1999
## 4       toyota corolla   1.8  2008
## 5       toyota corolla   1.8  2008

You should now be able to find your way around dataframes. If you are having trouble, you can always go over this section again until you are familiar with what to do.









Saturday, July 25, 2020

Kampala City Tour | Uganda | Vlog-1

Tuesday, July 21, 2020

How to solve ASP.NET MVC Exception: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated

ASP.NET MVC can give this error probably when you have a long running query. It can happen when:
1. You are running query on a very large dataset
2. Your query is complex and inefficient
3. Database statistics and/or query plan cache are incorrect
4. You are in deadlock

You should be able to find out the specific problem you are facing from stack trace.

Solutions:

Step 1:
If your query needs more than the default 30 seconds, you might want to set the CommandTimeout higher. To do that you'll change it after you instantiated the DataAdapter on the SelectCommand property of that instance, like so:

        protected DataTable GetDataTable(string Query, CommandType cmdType, params SqlParameter[] parameters)
        {
            string strCon = DataContext.Database.Connection.ConnectionString;
            DataTable dt = new DataTable();
            using (SqlConnection con = new SqlConnection(strCon))
            {
                using (SqlCommand cmd = new SqlCommand(Query, con))
                {
                    cmd.CommandType = cmdType;
                    cmd.Parameters.AddRange(parameters);
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        da.SelectCommand.CommandTimeout = 60 * 10;
                        da.Fill(dt);
                    }
                }
            }
            return dt;
        }


Step 2:
To reduce query complexity you need to apply different efficient methods to rewrite query as there is no specific method for improving query performance. You can apply indexing if you have large datasets. DBCC command is helpful to re-index and rebuild indexes which can also improve if you have large datasets.
DBCC DBREINDEX ('HumanResources.Employee', ' '); 


Step 3:

Improve database table query plan statiscs for all tables and index with a single command:

exec sp_updatestats

If that doesn't work you could also try

dbcc freeproccache

Hope this can be helpful.

Wednesday, June 24, 2020

Introduction to Continuous Integration and Continuous Delivery

Software Development Life Cycle


Software development follows a flow, starting with identifying new features, planning, doing the actual development, committing the source code changes, running builds and tests (unit, integration, functional, acceptance, etc.), and deploying to production.

With a traditional waterfall software delivery approach, developers could work independently for a very long time. They would not have a clue about how many issues they would run into during the integration phase.

In order to address this issue, the Agile software development model was introduced. Agile changed the way software development teams worked. One of the key principles of this methodology was delivering working software frequently. The focus moved to releasing incremental software, rather than big bang waterfall releases which took months and years.

Delivering software frequently meant producing stable code for every incremental release. It was quite a challenge to integrate changes from various developers on the teams. This led to software teams looking for better approaches. Continuous Integration (CI) offered a ray of hope and started to gain in popularity.


Continuous Integration (CI)


Continuous Integration is an agile engineering practice originating from the extreme programming methodology. It primarily focuses on automated build and test for every change committed to the version control system by the developers.



In order to implement Continuous Integration, you will need:

      • A version control system
        It stores all the source code checked in by the teams, and acts as the single source of truth.
      • Automated build and unit test
        It is not sufficient if the code written by a developer works only on his/her machine. Every commit that makes it to the version control system should be built and tested by an independent continuous integration server.
      • Feedback
        Developers should get feedback on their commits. Anytime a developer’s change breaks the build, they can take the necessary action (example: email notifications).
      • Agreement on ways of working
        It is important that everyone on the team follows the practice of checking-in incremental changes rather than waiting till they are fully developed. Their priority should be to fix any build issues that may arise with the checked-in code.

Continuous Delivery


Continuous Delivery is a logical extension of Continuous Integration. While Continuous Integration lets you automate the software build and test process, Continuous Delivery automates the full application delivery process by taking any change in code (new features, bug fixes, etc.) all the way from development (code commit) to deployment (to environments such as staging and production). It ensures that you are able to release new changes to your customers quickly in a reliable and repeatable manner.


Incorporating Continuous Delivery practices will make your overall release process painless, reduce the time to market for new features, and increase the overall quality of software thereby leading to greater customer satisfaction. It can also significantly reduce your software development costs as your teams will prioritize releasing new features over debugging defects.


Continuous Deployment


Oftentimes, the terms Continuous Delivery and Continuous Deployment are used synchronously by many, but in reality these concepts have a different meaning.

While Continuous Delivery gives you the capability to deploy to production frequently, it does not necessarily mean that you are automating the deployment. You may need manual approval prior to deploying to production, or your business may not want to deploy frequently.

Continuous Deployment, however, is an automated way of deploying your releases to production. You need to be doing continuous delivery in order to be able to perform automated deployment. Companies like Netflix, Amazon, Google, and Facebook automatically deploy to production multiple times a day.


Deployment Pipelines



Deployment pipelines (or Continuous Delivery pipelines) are the cornerstone of Continuous Delivery as they automate all the stages (build, test, release, etc.) of your software delivery process.

There are numerous benefits to using Continuous Deployment pipelines. An automated pipeline allows all stakeholders to monitor the progress, eliminates the overhead of all the manual work, provides quick feedback, and more importantly builds confidence on the code quality.


The deployment pipeline run starts with a developer committing source code change into a version control repository. The CI server detects the new commit, compiles the code, and runs unit tests. The next stage is deploying the artifacts (files generated from a build) to staging or a feature test environment where you run additional functional, regression, and acceptance tests. Once all the tests are successful, you are ready to deploy into production. In case of failure during any stage, the workflow stops and an immediate feedback is sent back to the developer.



Tools for Deployment Pipeline



In order to automate the various stages of your deployment pipeline, you will need multiple tools. For example:

      • a version control system such as Git to store your source code
      • a Continuous Integration (CI) tool such as Jenkins to run automated builds
      • test frameworks such as xUnit, Selenium, etc., to run various test suites
      • a binary repository such as Artifactory to store build artifacts
      • configuration management tools such as Ansible
      • a single dashboard to make the progress visible to everyone
      • frequent feedback in the form of emails, or Slack notifications.

And that’s not all. You will also need a single tool that can bring all these tools together to achieve CI/CD goals which is to automate software delivery.


Saturday, May 30, 2020

How to make a google map from excel, customize map view and share with p...







Here I show how to make a google map from excel file. Google map allows you to create custom map by uploading location data from excel or other format. You can customize base map view, share with people, embed to website or print to pdf.



The video of creating a google map from excel data file not only shows how to create a google map but also discuss on following google map features:

1. Importing excel data to map

2. Applying style to placemarker

 3. Applying label to placemarker

4. Apply base map

5. Display Map Preview

6. Sharing options

7. Adding a new place marker

 8. Routing line drawing between places

9. Direction between places

10. Distance measurement between places

11. How to print map

12. How to embed to website

13. Create new map using existing map



Please watch till the end of the video, I hope you will enjoy it.

If you have enjoy the video, please go ahead and like it.

Write us in comment how helpful this video for you. If you think this might be helpful for your friends, Please share the video with your friends.

If you have any question, regarding the video, Please write us through comments.

Please join in our community through subscription of channel and subscription of video notification.



In triksbuddy channel, you will get different interesting tech stuffs that will help you enrich your technology knowledge. Please subscribe our channel to get updates of our videos. Subscription link: https://goo.gl/GE4g8v



 Please subscribe in below link and like our video.

Subscription URL: https://goo.gl/GE4g8v

Channel URL: https://goo.gl/VYi58K

Most Recent Videos: https://goo.gl/hXFN4w

Most Popular Video: https://goo.gl/7u7B1x



Social:

Facebook: https://www.facebook.com/triksbuddy/

Linked in: https://www.linkedin.com/company/trik...

Blog: https://triksbuddy.blogspot.com/

Tumblr: https://imrulquaes89.tumblr.com/

RSS Feed: https://www.youtube.com/feeds/videos....



 Referral links that will not charge you but help me earning commissions:
Buy tubebuddy for your channel: https://bit.ly/2HP5lJR

Sunday, April 5, 2020

How To Schedule And Join A Zoom Meeting in Two Minutes







Learn how To Schedule And Join A Zoom Meeting with your free account in Two Minutes. In this video tutorial, I show you how to set up,  schedule and invite people to a zoom meeting, and how host and initiate a zoom meeting. You can host user conferences, executive briefing centers, customer and prospect events, webinars, or training sessions virtually over Zoom.

Zoom is the leader in modern enterprise video communications, with an easy, reliable cloud platform for video and audio conferencing, chat, and webinars. Zoom is a great video conferencing platform that allows you to schedule and hold video conference meetings with your team.

Zoom is removing the 40 min time limit on our Basic free account for K-12 schools affected by the COVID-19 Corona virus.

During corona virus situation, adapt to remote working, stay connected and productive in a remote work environment with the use of zoom.





Please watch till the end of the video, I hope you will enjoy it.

If you have enjoy the video, please go ahead and like it.

Write us in comment how helpful this video for you. If you think this
might be helpful for your friends, Please share the video with your
friends.

If you have any question, regarding the video, Please write us through
comments.



Please join in our community through subscription of channel and
subscription of video notification.

In triksbuddy channel, you will get different interesting tech stuffs
that will help you enrich your technology knowledge.



Please subscribe
our channel to get updates of our videos.

Subscription link:
https://goo.gl/GE4g8v



Please subscribe in below link and like our video.

Subscription URL: https://goo.gl/GE4g8v

Channel URL: https://goo.gl/VYi58K

Most Recent Videos: https://goo.gl/hXFN4w

Most Popular Video: https://goo.gl/7u7B1x

Social:
Facebook: https://www.facebook.com/triksbuddy/

Linked in: https://www.linkedin.com/company/triksbuddy/

Blog: https://triksbuddy.blogspot.com/

Tumblr: https://www.tumblr.com/blog/imrulquaes89

RSS Feed:
https://www.youtube.com/feeds/videos.xml?channel_id=UCKFouta2JOolZmAmHeo3ZKw