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 #2: [Count numbers which can be constructed using two numbers]

Here is the problem:

Given three positive integers x, y and n, the task is to find count of all numbers from 1 to n that can be formed using x and y. A number can be formed using x and y if we can get it by adding any number of occurrences of x and/or y.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains the integers x, y and n respectively.

Output:

Print the count of all numbers between 1 and n which can be formed using x and y. Print the answer for each test case in a new line.

Constraints:
1<= T <=100
1<= x, y, n <=100000

Example:
Input:
2
2 3 10
5 7 10
Output:
9
3
Explanation:
Input : n = 10, x = 2, y = 3
Output : 9
We can form 9 out of 10 numbers using 2 and 3 and 10 2 = 2, 3 = 3, 4 = 2+2, 5 = 2+3, 6 = 3+3 7 = 2+2+3, 8 = 3+3+2, 9 = 3+3+3 , 10 = 3+3+2+2.


This problem is more mathematical. Here is explanation:
 My Code:
In this code , the most important thing is the vector . We remember the values in the vector that are derived from x and y already
 
Let's see the example below: (Follow the code where start from 'for')

x=1; y= 2; n=5;
>> i=min(x,y) = 1;  IS i<=5 ? Yes #continue;

>> IS i>=1 or i>=2 ? Yes #continue;
>> IS i>=1 and Numbers[i-1]=true ? NO
>> IS i>=2 and Numbers[i-2]=true ? NO
>> IS i=1 ? YES #counter+1; #Number[i]=true;


Continue like this to i=5;

Popular posts from this blog

Math Problem -> Combinatorics: Foreign alphabet

Competitive Programming #29 : [LineUp]

Intro to Quantum Computing: Што ќе ми треба ова сега? #1