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 #13 : [The Mighty Divisible Number]

Given four numbers X, Y, Z and N. Your task is to find smallest N digit Number that is divisible by all the three numbers X, Y and Z.
Note: If no such number can be formed then print "-1".

Input:
The first line of the input contains an integer T, denoting the number of test cases. Then T test case follows. The only line of each test case contains four space separated integers denoting the values of X, Y, Z and N respectively.


Output:
For each test case output the smallest N digit number divisible by X, Y and Z. If no such number can be formed then print "-1".


Constraints:
1<=T<=103
1<=X,Y,Z<=103
1<=N<=18

Example:
Input:

3
2 3 5 4
4 5 6 3
3 5 7 2
Output:
1020
120
-1


Solution:
 
So how gonna this works ?
The most important thing here is LCM (x,y,z);
if LCM is greater or equal ten*10 it is impossible to get result about any three numbers (ten is smallest n digits number, example: the smallest 3 digits number is 1000 ) 
if LCM == 1 (if  lcm*ten = ten) then  print value of ten;
if LCM is smaller than ten then printf ten + (LCM-(ten%LCM)); 
else LCM is more than ten && LCM is smaller than ten*10 then  printf LCM;

Popular posts from this blog

Math Problem -> Combinatorics: Foreign alphabet

Competitive Programming #29 : [LineUp]

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