Non-Line-of-Sight (NLoS) propagation condition is a crucial factor affecting the precision of the localization in the Ultra-Wideband (UWB) Indoor Positioning System (IPS). Numerous supervised Machine Learning (ML) approaches have been applied for NLoS identification to improve the accuracy of the IPS. However, it is difficult for existing ML approaches to maintain a high classification accuracy when the database contains a small number of NLoS signals and a large number of Line-of-Sight (LoS) signals. The inaccurate localization of the target node caused by this small number of NLoS signals can still be problematic. To solve this issue, we propose feature-based Gaussian Distribution (GD) and Generalized Gaussian Distribution (GGD) NLoS detection algorithms. By employing our detection algorithm for the imbalanced dataset, a classification accuracy of $96.7\%$ and $98.0\%$ can be achieved. We also compared the proposed algorithm with the existing cutting-edge such as Support-Vector-Machine (SVM), Decision Tree (DT), Naive Bayes (NB), and Neural Network (NN), which can achieve an accuracy of $92.6\%$, $92.8\%$, $93.2\%$, and $95.5\%$, respectively. The results demonstrate that the GGD algorithm can achieve high classification accuracy with the imbalanced dataset. Finally, the proposed algorithm can also achieve a higher classification accuracy for different ratios of LoS and NLoS signals which proves the robustness and effectiveness of the proposed method.