MeanNearestNeighbors (MNN) - algorithm for balancing dataset - In progress #1

Image
One of the challenges in classification problems are unbalanced datasets. I was Data Science Intern when the company that I worked for, assigned me such an interesting challenge where the dataset was unbalanced.  However, I realized this type of problem like unbalanced dataset is а common thing in real life. I tried most of the algorithms (undersampling, oversampling) like SMOTE, NearMiss, CondensedNearestNeighbors, RandomUnderSampler, RandomOverSampler,  KMeansSMOTЕ and rest of them. Anyway, they didn't help me in that case, on the contrary, they worsened my model.  I was like: "but, but, you should have been helpful in creating the predictive model" So, I'm trying to create another algorithm based on undersampling concept when it comes to balancing datasets. I called it Mean Nearest Neighbors (MNN). What's the initial idea: It's simple. Actually, the algorithm is just a modification of the other undersampling algorithms. In the data where target labe...

Competitive Programming #20: [Non-Repeating Element]

Find the first non-repeating element in a given array of integers.
Note: Array consists of only positive and negative integers and not zero.
Input:
The first line of input is an integer T, denoting the number of test cases. Each test case has subsequent two lines of input. First line is an integer N, denoting size of integer array A. Second line consists of N space separated integers of the array A.
Output:
The only line of output for each test case is the first non-repeating element in the array A. If there is no such element, print 0 as the output.
Constraints:
1<=T<=100;
1<=N<=100;
A[i] belongs to [-100,100]-{0}, where i is an integer denoting index of array.

Example:
Input:
4
5
-1 2 -1 3 2
6
9 4 9 6 7 4
3
1 1 1
2
-3 2


Output:
3
6
0
-3

Explanation:
In the first test case, -1 and 2 are repeating whereas 3 is the only number occuring once. Hence, the output is 3.
In the second test case, there are 3 distinct integers, 9, 4 and 5, but they all are repeating. There is no non-repetitive element in the array. Hence, the output is 0.
In the third test case, -1 and 3 are non-repeating. -1 occurs before 3 in the array. Hence, the output is -1.
In the fourth test case, there are two distinct elements occuring only once in the array, with 6 occuring before 7. Hence, output is 6.
In the fifth test case, the only non-repeating element is -3. Hence, output is -3.
_________________________________________________________________
Solution:
 
Easy one !!! ... lets first input array of integers [-100,100] then we count them