[1] "Predicting sugar corruption in public distribution system"
[1] "Predict the shop location which is performed sugar corruption.View the data in hierarchical view of location and clustering the people according to cards, district, office, shop and try to detect the corruption of sugar in ration shop."
[1] "Organization: Telangana State Civil Supplies Corporation Limited\n\nThe dataset about the FP Shop Distribution data in Telangana.\n\nThis dataset contains 16970 obs. of 13 variables: \n \ndistCode : District Code\n\nofficeCode : Represents the office code\n\nshopNo : Representing Shop number\n\nnoOfRcs : No.of Ration Cards\n\nnoOfTrans: No.of Transactions\n\nriceAfsc : Rice to Anthtodaya Food Security Cards\n\nriceFsc : Rice to Food Security Card\n\nriceAap : Rice to Annapurna Card\n\nsugar : sugar quantity\n\ntotalAmount : total amount\n\notherShopTransCnt : Other shops transaction quantity"
Link to Preprocessing the Data
'data.frame': 16979 obs. of 19 variables:
$ distCode : int 532 532 532 532 532 532 532 532 532 532 ...
$ distName : chr "Adilabad" "Adilabad" "Adilabad" "Adilabad" ...
$ officeCode : int 532001 532001 532001 532001 532001 532001 532001 532001 532001 532001 ...
$ officeName : chr "Talamadugu" "Talamadugu" "Talamadugu" "Talamadugu" ...
$ shopNo : int 1901001 1901002 1901003 1901004 1901005 1901006 1901007 1901008 1901009 1901010 ...
$ month : int 1 1 1 1 1 1 1 1 1 1 ...
$ year : int 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 ...
$ noOfRcs : int 973 515 254 364 871 460 488 333 315 840 ...
$ noOfTrans : int 974 516 255 366 873 460 534 336 315 844 ...
$ riceAfsc : num 1330 595 560 490 5075 ...
$ riceFsc : num 18174 10050 4824 7212 15756 ...
$ riceAap : num 0 0 0 0 0 0 0 0 0 0 ...
$ wheat : num 0 0 0 0 0 0 0 0 0 0 ...
$ sugar : num 0 0 15 0 145 36 9 0 0 110 ...
$ rgdal : num 0 0 0 0 0 0 0 0 0 0 ...
$ kerosene : num 0 0 0 0 0 0 0 0 0 0 ...
$ totalAmount : num 19504 10645 5586 7702 22788 ...
$ salt : num 0 0 0 0 0 0 0 0 0 0 ...
$ otherShopTransCnt: int 19 11 4 5 16 8 15 4 5 26 ...
[1] 16979 19
distCode distName officeCode officeName
0 0 0 0
shopNo month year noOfRcs
0 0 0 0
noOfTrans riceAfsc riceFsc riceAap
0 0 0 0
wheat sugar rgdal kerosene
0 0 0 0
totalAmount salt otherShopTransCnt
0 0 0
distCode distName officeCode officeName
Min. :532 Length:16979 Min. :532001 Length:16979
1st Qu.:539 Class :character 1st Qu.:539021 Class :character
Median :926 Mode :character Median :926013 Mode :character
Mean :786 Mean :786030
3rd Qu.:934 3rd Qu.:934022
Max. :982 Max. :982012
shopNo month year noOfRcs noOfTrans
Min. :1407001 Min. :1 Min. :2021 Min. : 1.0 Min. : 1.0
1st Qu.:2110004 1st Qu.:1 1st Qu.:2021 1st Qu.: 276.0 1st Qu.: 277.0
Median :2913002 Median :1 Median :2021 Median : 386.0 Median : 388.0
Mean :2919701 Mean :1 Mean :2021 Mean : 426.3 Mean : 428.2
3rd Qu.:3722020 3rd Qu.:1 3rd Qu.:2021 3rd Qu.: 519.0 3rd Qu.: 521.0
Max. :4612012 Max. :1 Max. :2021 Max. :4206.0 Max. :4207.0
riceAfsc riceFsc riceAap wheat
Min. : 0 Min. : 0 Min. : 0.000 Min. : 0.00
1st Qu.: 560 1st Qu.: 4944 1st Qu.: 0.000 1st Qu.: 0.00
Median : 875 Median : 7002 Median : 0.000 Median : 0.00
Mean :1028 Mean : 8011 Mean : 2.277 Mean : 73.91
3rd Qu.:1260 3rd Qu.: 9660 3rd Qu.: 0.000 3rd Qu.: 0.00
Max. :9765 Max. :83310 Max. :320.000 Max. :5343.00
sugar rgdal kerosene totalAmount
Min. : 0.0 Min. :0 Min. : 0.000 Min. : 3
1st Qu.: 0.0 1st Qu.:0 1st Qu.: 0.000 1st Qu.: 6006
Median : 8.0 Median :0 Median : 0.000 Median : 8432
Mean : 15.8 Mean :0 Mean : 8.072 Mean : 10053
3rd Qu.: 26.0 3rd Qu.:0 3rd Qu.: 0.000 3rd Qu.: 11584
Max. :269.0 Max. :0 Max. :1196.000 Max. :150884
salt otherShopTransCnt
Min. :0.000000 Min. : 0.0
1st Qu.:0.000000 1st Qu.: 12.0
Median :0.000000 Median : 33.0
Mean :0.000825 Mean : 109.4
3rd Qu.:0.000000 3rd Qu.: 139.0
Max. :9.000000 Max. :2225.0
[1] Adilabad Bhadrdri Kothagudem Hanumakonda
[4] Hyderabad Jagityal Janagaon
[7] Jayashankar Bhupalpalli Jogulamba Gadwal Kamareddy
[10] Karimnagar Khammam Kumarambheem Asifabad
[13] Mahabubabad Mahbubnagar Manchiryala
[16] Medak Medchal Mulugu
[19] Nagarkarnool Nalgonda Narayanpet
[22] Nirmal Nizamabad Peddapalli
[25] Rajanna Siricilla Ranga Reddy Sangareddy
[28] Siddipet Suryapet Vikarabad
[31] Wanaparthy Warangal Yadadri Bhuvanagiri
33 Levels: Adilabad Bhadrdri Kothagudem Hanumakonda Hyderabad ... Yadadri Bhuvanagiri
Link to EDA
### Histogram of sub1.distCode
sugar distCode noOfRcs noOfTrans riceAfsc totalAmount
1.0000000 -0.1258924 0.3438989 0.3454054 0.5889668 0.3541197
Welch Two Sample t-test
data: sugar_urban and sugar_rural
t = 8.0677, df = 5692.8, p-value = 8.663e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
2.505767 4.114406
sample estimates:
mean of x mean of y
18.38980 15.07972
Link to EDA
---
title: "Public Distributed system part-1"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: scroll
theme: simplex
social: menu
source_code: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(ggplot2)
library(lattice)
library(dplyr)
library(tidyverse)
library(cluster)
library(NbClust)
library(GGally)
library(rgl)
library(scatterplot3d)
library(useful)
```
Column {data-width=650}
-----------------------------------------------------------------------
### Objective :
```{r}
print("Predicting sugar corruption in public distribution system")
```
### Problem Statement :
```{r}
print("Predict the shop location which is performed sugar corruption.View the data in hierarchical view of location and clustering the people according to cards, district, office, shop and try to detect the corruption of sugar in ration shop.")
```
### Dataset Description :
```{r}
"Organization: Telangana State Civil Supplies Corporation Limited
The dataset about the FP Shop Distribution data in Telangana.
This dataset contains 16970 obs. of 13 variables:
distCode : District Code
officeCode : Represents the office code
shopNo : Representing Shop number
noOfRcs : No.of Ration Cards
noOfTrans: No.of Transactions
riceAfsc : Rice to Anthtodaya Food Security Cards
riceFsc : Rice to Food Security Card
riceAap : Rice to Annapurna Card
sugar : sugar quantity
totalAmount : total amount
otherShopTransCnt : Other shops transaction quantity"
```
Link to [Preprocessing the Data]
# Preprocessing the Data
Column {data-width=500}
-----------------------------------------------------------------------
### DataStructure
```{r}
data <- read.csv("/cloud/project/shop-wise-trans-detailsTelangana State Civil Supplies Distribution - FP Shop Wise Transactions Data_01-01-2021 to 31-01-2021.csv")
str(data)
```
### Dimension of dataset
```{r}
dim(data)
```
### Checking null values
```{r}
colSums(is.na(data))
```
### Summary of the data
```{r}
summary(data)
```
### Create new attribute using existing attribute
```{r}
distric_class = data.frame(
distName=c("Adilabad","Bhadrdri Kothagudem","Hanumakonda","Hyderabad","Jagityal","Janagaon","Jayashankar Bhupalpalli","Jogulamba Gadwal","Kamareddy","Karimnagar","Khammam","Kumarambheem Asifabad","Mahabubabad","Mahbubnagar","Manchiryala","Medak","Medchal","Mulugu","Nagarkarnool","Nalgonda","Narayanpet","Nirmal","Nizamabad","Peddapalli","Rajanna Siricilla","Ranga Reddy","Sangareddy","Siddipet","Suryapet","Vikarabad","Wanaparthy","Warangal","Yadadri Bhuvanagiri" ),
Classifi=c("Rural","Rural","Urban","Urban","Rural","Urban","Rural","Rural","Rural","Rural","Rural","Rural","Rural","Rural","Rural","Rural","Rural","Rural","Rural","Rural","Rural","Urban","Rural","Rural","Rural","Urban","Rural","Rural","Urban","Rural","Urban","Rural","Rural"))
factor(distric_class$distName)
#Merge the classification data with the main dataset based on district names
sub1=merge(data,distric_class,by='distName',,all.x=TRUE)
data=sub1
```
Link to [EDA]
# EDA
Column {data-width=500}
-----------------------------------------------------------------------
### Univariate Ananlysis
### Histogram of number of ration cards
```{r}
ggplot(data
, aes(x = noOfRcs)) +
geom_histogram(bins = 30) +
labs(title = "Distribution of Number of Ration Cards", x = "Number of Ration Cards")
```
### Histogram of sub1.distCode
```{r}
ggplot(data, aes(x = distCode)) +
geom_histogram(binwidth = 50, fill = "skyblue", color = "black") +
labs(title = "Histogram of distCode", x = "distCode", y = "Frequency")
```
### Histogram of noOfTrans
```{r}
ggplot(data, aes(x = noOfTrans)) +
geom_histogram(binwidth = 50, fill = "skyblue", color = "black") +
labs(title = "Histogram of noOfTrans", x = "noOfTrans", y = "Frequency")
```
### Histogram of riceAfsc
```{r}
ggplot(data, aes(x = riceAfsc)) +
geom_histogram(binwidth = 50, fill = "skyblue", color = "black") +
labs(title = "Histogram of riceAfsc", x = "riceAfsc", y = "Frequency")
```
Column {data-width=500}
-----------------------------------------------------------------------
### Histogram of riceFsc
```{r}
ggplot(data, aes(x = riceFsc)) +
geom_histogram(binwidth = 50, fill = "skyblue", color = "black") +
labs(title = "Histogram of riceFsc", x = "riceFsc", y = "Frequency")
```
### Histogram of riceAap
```{r}
ggplot(data, aes(x = riceAap)) +
geom_histogram(binwidth = 50, fill = "skyblue", color = "black") +
labs(title = "Histogram of riceAap", x = "riceAap", y = "Frequency")
```
### Histogram of sugar
```{r}
ggplot(data, aes(x = sugar)) +
geom_histogram(binwidth = 50, fill = "skyblue", color = "black") +
labs(title = "Histogram of sugar", x = "sugar", y = "Frequency")
```
### Histogram of totalAmount
```{r}
ggplot(data, aes(x = totalAmount)) +
geom_histogram(binwidth = 50, fill = "skyblue", color = "black") +
labs(title = "Histogram of totalAmount", x = "totalAmount", y = "Frequency")
```
### Histogram of otherShopTransCnt
```{r}
ggplot(data, aes(x = otherShopTransCnt)) +
geom_histogram(binwidth = 50, fill = "skyblue", color = "black") +
labs(title = "Histogram of otherShopTransCnt", x = "otherShopTransCnt", y = "Frequency")
```
### Histogram of X
```{r}
histogram_10 <- ggplot(data, aes(x = X)) +
geom_histogram(binwidth = 50, fill = "skyblue", color = "black") +
labs(title = "Histogram of X", x = "X", y = "Frequency")
```
```{r}
#bivariant analysis
# Bar plot of 'Classifi' vs. 'noOfTrans'
ggplot(data, aes(x = Classifi, fill = Classifi)) +
geom_bar() +
labs(x = "Classification", y = "Number of Transactions") +
ggtitle("Number of Transactions by Classification")
# Bar plot of 'distCode' vs. 'riceAfsc'
ggplot(data, aes(x = distCode, y = riceAfsc)) +
geom_bar(stat = "identity") +
labs(x = "District Code", y = "Rice Amount") +
ggtitle("Rice Amount by District Code")
# Bar plot of 'officeCode' vs. 'sugar'
ggplot(data, aes(x = officeCode, y = sugar)) +
geom_bar(stat = "identity") +
labs(x = "Office Code", y = "Sugar Amount") +
ggtitle("Sugar Amount by Office Code")
# Example: Bar chart for 'officeCode' vs. 'totalAmount'
ggplot(data, aes(x = factor(officeCode), y = totalAmount)) +
geom_bar(stat = "identity") +
labs(x = "Office Code", y = "Total Amount") +
ggtitle("Total Amount by Office Code")
# Example: Bar chart for 'distCode' vs. 'totalAmount'
ggplot(data, aes(x = factor(distCode), y = totalAmount)) +
geom_bar(stat = "identity") +
labs(x = "District Code", y = "Total Amount") +
ggtitle("Total Amount by District Code")
# Example: Bar chart for 'Classifi' vs. 'totalAmount'
ggplot(data, aes(x = Classifi, y = totalAmount)) +
geom_bar(stat = "identity") +
labs(x = "Classification", y = "Total Amount") +
ggtitle("Total Amount by Classification")
# Box plot of 'distCode' vs. 'totalAmount'
ggplot(data, aes(x = factor(distCode), y = totalAmount)) +
geom_boxplot() +
labs(x = "District Code", y = "Total Amount") +
ggtitle("Box Plot of Total Amount by District Code")
# Box plot of 'officeCode' vs. 'totalAmount'
ggplot(data, aes(x = factor(officeCode), y = totalAmount)) +
geom_boxplot() +
labs(x = "Office Code", y = "Total Amount") +
ggtitle("Box Plot of Total Amount by Office Code")
# Box plot of 'Classifi' vs. 'totalAmount'
ggplot(data, aes(x = factor(Classifi), y = totalAmount)) +
geom_boxplot() +
labs(x = "Classification", y = "Total Amount") +
ggtitle("Box Plot of Total Amount by Classification")
#scatteplot
# Scatter plot of 'noOfRcs' vs. 'totalAmount'
ggplot(data, aes(x = noOfRcs, y = totalAmount)) +
geom_point() +
labs(x = "Number of Records", y = "Total Amount") +
ggtitle("Scatter Plot: Number of Records vs. Total Amount")
# Scatter plot of 'noOfTrans' vs. 'totalAmount'
ggplot(data, aes(x = noOfTrans, y = totalAmount)) +
geom_point() +
labs(x = "Number of Transactions", y = "Total Amount") +
ggtitle("Scatter Plot: Number of Transactions vs. Total Amount")
# Scatter plot of 'riceAfsc' vs. 'totalAmount'
ggplot(data, aes(x = riceAfsc, y = totalAmount)) +
geom_point() +
labs(x = "Rice AFSC", y = "Total Amount") +
ggtitle("Scatter Plot: Rice AFSC vs. Total Amount")
# Scatter plot of 'riceFsc' vs. 'totalAmount'
ggplot(data, aes(x = riceFsc, y = totalAmount)) +
geom_point() +
labs(x = "Rice FSC", y = "Total Amount") +
ggtitle("Scatter Plot: Rice FSC vs. Total Amount")
# Scatter plot of 'riceAap' vs. 'totalAmount'
ggplot(data, aes(x = riceAap, y = totalAmount)) +
geom_point() +
labs(x = "Rice AAP", y = "Total Amount") +
ggtitle("Scatter Plot: Rice AAP vs. Total Amount")
```
```{r}
#correlation
# select specific columns for correlation analysis
selected_columns <- data[, c("sugar", "distCode", "noOfRcs", "noOfTrans", "riceAfsc", "totalAmount")]
# Calculate the correlation matrix
correlation_matrix <- cor(selected_columns)
# Print the correlation coefficients related to 'sub1.sugar'
print(correlation_matrix["sugar", ])
#testing
# Filter data for urban and rural areas
sugar_urban <- data[data$Classifi == "Urban", "sugar"]
sugar_rural <- data[data$Classifi == "Rural", "sugar"]
# Perform independent t-test
t_test_result <- t.test(sugar_urban, sugar_rural)
# Print the result
print(t_test_result)
```
Link to [EDA]