Thursday, February 22, 2024

LIS 4317 Visual Analytics - Module 7 Assignment

For this week's assignment, we are tasked with creating visual analytics based on distribution analysis. I will be working with the mtcars dataset to understand the distribution of horsepower (hp).

A quick note, I generated a couple visuals of the horsepower (hp) distribution:

Scatter plot:

Boxplot:

Line Graph:

Histogram:

Reflecting on Few's recommendations in testing and best practices when it comes to conducting distribution analysis, each of my graphs have strengths and weaknesses. To begin, Few notes that there are three main characteristics when it comes to describing distributions. These are...

Spread: A simple measure of dispersion, or how spread out the values are and it essentially is the full range of values from highest to lowest.

Center: An estimate of the middle of a set of values and it is often demonstrated by either the mean or median.

Shape: Where the values are located throughout the spread. 

For the most part, my visuals do a good job of showing spread except for maybe the boxplot as it simplifies the values that are shown on the y-axis tick marks but the full spread is still albeit it is slightly downplayed. As for center, visuals 1, 3, and 4 provides horsepower's mean and median and where it lies in correspondence to the chart. The second visual, the boxplot, only provides the median. Moving on to shape, one can note that visuals 1, 3, and 4 appear slightly skewed to the right. In the histogram, one can also see a brief gap near the 300 tick mark and an outlier when hp equals 325. 

As for whether these visuals correspond to Few's distribution analysis best practices, I believe my visuals do a fairly good job when it comes to interval consistency but fails when it comes to outlier resistance. As one can tell from the visuals, there is a clear outlier where hp equals 325. The mean calculation can be heavily affected by outliers and as a result, can be shifted in the direction of that outlier and we can clearly see that happening here. Therefore, it might be a good idea to remove that outlier from the dataset before conducting visual analysis. 

All in all, Few's recommendations are incredibly helpful when it comes to deciphering data when it is visualized.

~ Katie

Wednesday, February 21, 2024

LIS 4370 R Programming - Module 7 Assignment

For this week's assignment, I will start out by examining the iris dataset and then transition to my own dataset when it comes to creating two examples of S3 and S4.

Question 1: Determine if a generic function can be applied to your dataset

To begin, I used the following functions on the iris dataset and came up with the following output:

Based on this output, I can confirm that a generic function can be applied to my chosen dataset.

Question 2: How do you tell what OO system (S3 vs. S4) an object is associated with?

In the library, pryr, one can use the function otype() to determine which OO system object is associated with.

In this case, the iris dataset is associated with S3.

Question 3: How do you determine what the base type of an object is?

Using the typeof() function can help in determining an object's base type. Continuing with the iris dataset, we can check the object type of each of the variables within the dataset:

Question 4: What is an generic function?

A generic function can be defined as a function that performs a common task like printing (print()) or even plotting (plot()). Furthermore, they can be thought as extended function objects because they contain information that is used in creating and dispatching for the function.

Question 5: What are the main differences between S3 and S4?

To put it simply, S3 is considered more convenient while S4 is more safe. Additionally, S3 classes are very straightforward to implement as it only uses the first argument to dispatch but it can allow for mistakes to slip through like misspelled values and missing values and will not alert the programmer of the potential issues. On the other hand, S4 classes and methods are way more formal and more closely related to object-oriented concepts and unlike S3, S4 will complain about such misspellings and other issues to alert the programmer that the current code does need to be fixed.

Question 6: Create two examples of S3 and S4. (Code will be linked to GitHub)

S3 Code:

Output:

S4: Code:

Output:

After conducting this brief code experiment, I must admit that I greatly prefer the form of S4 over S3 just for its ease of creating instances of the class. 

Link to GitHub Code: Module 7 Code

~ Katie

Thursday, February 15, 2024

LIS 4370 R Programming - Module 6 Assignment

 In this week in LIS 4370, we are asked to answer the following questions using R.

Question 1:

Consider A <- matrix(c(2, 0, 1, 3), ncol = 2) and B <- matrix(c(5, 2, 4, -1), ncol = 2)

a) Find A + B

b) Find A - B

Output:

Question 2:

Use the diag() function to to build a matrix of size 4 with the following values in the diagonal: 4, 1, 2, 3

Output:

Question 3:

Generate the following matrix:

Hint: Use the diag() command to build it.

Solution and Output:

Here's the link to the full code on GitHub: Module 6 Code

~ Katie

LIS 4317 Visual Analytics - Module 6 Assignment

For this week, we were tasked with creating a simple data visualization using R. I decided to work with the mtcars dataset which comes as a prebuilt dataset in R and lists various cars from the 1974 Motor Trends US magazine.

There are many variables to look at but I wanted to examine all the average miles per gallon (mpg) for each of the cars listed.

To do so, I used ggplot2 and came up with the following:


(Click on the image to make it bigger)

Reflecting on Few and Yau's discussions on conducting basic visualizations, my visualization somewhat follows the various design principles they introduced. Such as, selecting the right type of graph that best visualizes the data in a meaningful way. As Few mentions in page 37 of the textbook, not all graphs can effectively show the data. With this many car names, a pie chart would not be suitable in order to tell the differences between mpg. 

If I were to revise this visualization, I would attempt to create space between each bar to better make out which car belongs to which bar. It is a bit condensed and spacing is needed. Next, the color scheme is pretty but can get quite hard to see when it comes to reading colored bars between the colors orange, green, blue, and pink. 

~ Katie 


Tuesday, February 6, 2024

LIS 4370 R Programming - Module 5 Assignment

For this assignment, I will be doing math with the following matrices:

For the most part, I used the explanation that was provided through the course announcements as a guide to doing this assignment. To begin, it is important to note that these two matrices above will not produce any inverses. 

We can check for inverses by using the det() function which gives us the determinant of a matrix. Entering into R det(A) and det(B), we can see in the console that det(A) will come out with zero while det(B) will give an error because det(B) is not a square matrix.

Now, what is a square matrix exactly? Well, it's a matrix with the same number of rows and columns which allows for one to add and multiply with it. Looking at the structure of the matrix when we transpose the matrices, we can immediately see that the rows greatly outnumber the columns whereas the A matrix does contain the same number of rows and columns (10 rows by 10 columns).

Moving on in the code, we are asked to create two vectors called a and b and since we intend to multiply them by the above matrices, we must make sure that the vector length matches the number of matrix rows. We then create the following vectors:

Moving onto the multiplication of the vectors and matrices, we can execute the following piece of code to perform the calculation:

The calculation is then saved to a table under the following variables:

result_1:

result_2:

The next step is to reassign the vectors a and b to equal the number of rows of the column for the corresponding matrix:

By executing the code, both a and b become of length 10.

Lastly, we are asked to multiply the matrices which can done through the following piece of code:

A taste of the output can be seen in the following image:

Here's a link to the code on GitHub:

Module 5 Code

~ Katie

LIS 4317 Visual Analytics - Module 5 Assignment

For this assignment, I will be working with a dataset containing data regarding average position and time. Following the part to whole design framework, I decided to focus on the part of  the data where time spans from half a second (0.5) to the maximum time recorded (3.8).

With a filtered dataset, I created a simple scatter plot with Plot.ly to graph the data.

Here's the plot:


Observing the plot, we can quickly see that as time increases, average position increases too. However, it appears that average position levels off around 1. More data is definitely needed to further understand why the data points seems to stop at this point.

Thinking about the Part to Whole Design Framework and how it applies to this plot, the first thing I appreciate is its ability to zoom in on an aspect of the data like time from 0.5 to 3.8. Sometimes, looking at the full picture of the data can be a bit overwhelming and you may miss key information. By taking a part of the data, we can clearly see that steady climb in position and time. 

Here's a link to the plot:

Module 5 Scatter Plot

~ Katie

Wednesday, January 31, 2024

LIS4317 Visual Analytics - Module 4 Assignment

For this assignment, I will generate visualizations based on monthly modal time series data from Data.gov. 

In the visualizations, I decided to use the following 6 variables:

Primary USA City, Year, Vehicle Revenue Miles, Vehicle Revenue Hours, Ridership, Collisions with Motor Vehicle, and Collisions with Person

Thinking about how to best visualize this data, the first thing I wanted to see was the overall rate of collisions over the years recorded.

To do this, I went with a bubble chart and as you can see, 2019 had the lowest rate of collisions compared to the others.

Legend for reference:

While this is interesting, I wanted to further compare collisions across select US major cities and came up with the following:


Legend for reference:

The top line chart represents collisions with motor vehicles while the bottom chart shows collisions with people. Immediately, we can see that New York City experiences the highest number of collisions but it is interesting to see how it trends downward very quickly in the course of a year between 2018 and 2019. Further, the other cities trended downward as well but look steady compared to New York City. 

See the visualizations up close here:

Bubble Chart

Line Chart

~ Katie


LIS 4370 R Programming - sentimentTextAnalyzer2 Final Project

For this class's major final project, I set out to make the process of analyzing textual files and URL links for sentiment insights much...