Posts

Showing posts from November, 2017

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 #5: [Smallest Positive missing number]

Image
You are given an unsorted array with both positive and negative elements. You have to find the smallest positive number missing from the array in O(n) time using constant extra space. Input: First line consists of T test cases. First line of every test case consists of N, denoting the number of elements in array. Second line of every test case consists of elements in array. Output: Single line output, print the smallest positive number missing. Constraints: 1<=T<=100 1<=N<=100 -100<=a[i]<=100 Example: Input: 2 5 1 2 3 4 5 5 0 -10 1 3 -20 Output: 6 2 Solution: Everything is said in the text above.  

Competitive Programming #4: Microsoft -> [Nth item through sum]

Image
This task is from Microsoft Interview: Given two sorted arrays, we can get a set of sums(add one element from the first and one from second). Find the N’th element in the set considered in sorted order. Note:  Set of sums should have unique elements. Input: The first line of input contains an integer T denoting tghe number of test cases. Then T test cases follow. Each test case contains two integers m and n denoting the size of the two arrays respectively. The next two lines contains m and n space separated elements forming both the arrays respectively. The last line contains the value of N. Output: Print the value of Nth element in set. If Nth element doesn't exist in set print -1. Constraints: 1<=T<=10^5 1<=m,n<=10^5 1<=arr1[i],arr2[j]<=10^5 1<=N<=m*n Example: Input: 2 2 2 1 2 3 4 3 5 4 1 3 4 8 10 20 22 30 40 4 Output: 6 25 Solution: This would be pretty easy task if m,n <=10^3 ... but it is 10^5  . So ...

C/C++ #1: C++ Books Online Download Free

Image
1. C++ for Dummies 5th Edition      2. C++ for Dummies 7th Edition   3.Learn C++ for Game Development   4.Programming : Principles and Practice Using C++   5. C++ Standard 2017 (draft)    

Artificial Intelligence #3

Image

Technology Things #3: What are some mind-blowing facts related to technology?

Image
The world wide web was created using NEXT computer, which does not exist now. Google hired a camel to create street view in desert. Sophia is the first ever robot to get a citizenship of Saudi Arabia. She was provided citizenship in October, 2017. If Facebook was a country, then it would have been the world's most populated country. One Bitcoin transaction consumes 3,994 times more energy than a credit card transaction. Candy Crush has more active monthly users than the entire population of Canada. Apple iPad would cost $14,970 (₹ 9,69,510) if made in the USA. Microsoft makes more money from Samsung's Android than they do from Windows phones, Skype and Xbox combined. As per the statistic of 2016, 54,907 Google searches, 7,252 tweets, 125,406 YouTube video views and 2,501,018 E-mails are sent per second in Internet. South Korea had the fastest average internet connection in the world.

Competitive Programming #3: [Fact Digit Sum]

Image
Here is the problem:  Let's define A(n) for positive integer  n  as a sum of factorials of its digits. For example, A(154)=1!+ 5! +4!= 145. Given a number 'x' , you need to print the minimum number L such that A(L)=x. If no such L exists, then print -1 Input: First line contains 'T' - the number of test cases Then each line contains an integer 'x'. Output: Print the answer for each value 'x'. Constraints: 1<=T<=542 1000<=x<=1000000000 Example: Input: 1 40321 Output: 18 Explanations: A(18)=1!+ 8! =40321  and 18 is the smallest element for which A(18) is 40321 Note that A(80) = A(81) is also 40321, But among them 18 is the smallest number. Solution: Another interesting problem. I thought it is hard problem but actually it is very easy.(Dont worry I am not good at all with competitive programming  :D ) The approach is with Greedy Algorithm ... So we have: It is with recursive function , if u still dont u...

Technology Things #2

Image

Artificial Intelligence #2

Image
Well, well , well ... maybe Elon Musk is right about danger of AI. But in this video there is a sentence where it reads like this: They used to say guns don't kill people, people do. Well people don't. They get emotional, disobey orders, aim high

Artificial Intelligence #1

Image
                                                                                                                                                              Interesting comments on Reddit: