<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Extra 2.1 - Unbalanced Data - Application 1
Step1:  Classification on unbalanced (original) data
Step2:  Cross Validation tests
Step3:  ## Classification on balanced data
Step4:  Balancing the data
With an unbalanced like the above, the resulted trained classifier will typically be skewed towards the majority labels. In order to mitigate this, we balance the dataset using the SMOTE Oversampling Method.
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
df = pd.read_csv("provstore/data.csv")
df.head()
df.describe()
# The number of each label in the dataset
df.label.value_counts()
Explanation: Extra 2.1 - Unbalanced Data - Application 1: ProvStore Documents
Identifying owners of provenance documents from their provenance network metrics.
In this notebook, we compared the classification accuracy on unbalanced (original) ProvStore dataset vs that on a balanced ProvStore dataset.
Goal: To determine if the provenance network analytics method can identify the owner of a provenance document from its provenance network metrics.
Training data: In order to ensure that there are sufficient samples to represent a user's provenance documents the Training phase, we limit our experiment to users who have at least 20 documents. There are fourteen such users (the authors were excluded to avoid bias), who we named $u_{1}, u_{2}, \ldots, u_{14}$. Their numbers of documents range between 21 and 6,745, with the total number of documents in the data set is 13,870.
Classification labels: $\mathcal{L} = \left{ u_1, u_2, \ldots, u_{14} \right} $, where $l_{x} = u_i$ if the provenance document $x$ belongs to user $u_i$. Hence, there are 14 labels in total.
Reading data
For each provenance document, we calculate the 22 provenance network metrics. The dataset provided contains those metrics values for 13,870 provenance documents along with the owner identifier (i.e. $u_{1}, u_{2}, \ldots, u_{14}$).
End of explanation
from analytics import test_classification
Explanation: Classification on unbalanced (original) data
End of explanation
results, importances = test_classification(df)
Explanation: Cross Validation tests: We now run the cross validation tests on the dataset (df) using all the features (combined), only the generic network metrics (generic), and only the provenance-specific network metrics (provenance). Please refer to Cross Validation Code.ipynb for the detailed description of the cross validation code.
End of explanation
from analytics import balance_smote
Explanation: ## Classification on balanced data
End of explanation
df = balance_smote(df)
results_bal, importances_bal = test_classification(df)
Explanation: Balancing the data
With an unbalanced like the above, the resulted trained classifier will typically be skewed towards the majority labels. In order to mitigate this, we balance the dataset using the SMOTE Oversampling Method.
End of explanation
<END_TASK>