Skip to content

Instantly share code, notes, and snippets.

View sourabhxyz's full-sized avatar
🏀
λ

Sourabh sourabhxyz

🏀
λ
View GitHub Profile
@sourabhxyz
sourabhxyz / model1.py
Created November 10, 2018 06:18
ML Mini Project - Model 1
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import json
import math
from datetime import datetime
from sklearn.ensemble import RandomForestRegressor
eps = 1e-6
def getMH (x):
x = datetime.fromtimestamp (x)
@sourabhxyz
sourabhxyz / model2.py
Created November 10, 2018 06:53
ML Mini Project - Model 2
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import json
import math
from datetime import datetime
from sklearn.ensemble import RandomForestRegressor
eps = 1e-6
def getMH (x):
x = datetime.fromtimestamp (x)
@sourabhxyz
sourabhxyz / model3.py
Created November 10, 2018 08:55
ML Mini Project - Model 3
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import json
import math
from datetime import datetime
from sklearn.ensemble import RandomForestRegressor
eps = 1e-6
def getMH (x):
x = datetime.fromtimestamp (x)
@sourabhxyz
sourabhxyz / model4.py
Created November 10, 2018 08:58
ML Mini Project - Model 4
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import json
import math
from datetime import datetime
from sklearn.ensemble import RandomForestRegressor
eps = 1e-6
def getMH (x):
x = datetime.fromtimestamp (x)
@sourabhxyz
sourabhxyz / model5.py
Created November 10, 2018 09:02
ML Mini Project - Model 5
# Took time of 1227.5 seconds (20 minutes 27 seconds) on kaggle server...
# Score:
# Private: 0.59736
# Public: 0.62892
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import json
import math
from datetime import datetime
@sourabhxyz
sourabhxyz / model6789.py
Created November 10, 2018 09:59
ML Mini Project - Model 6, 7, 8, 9
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import json
import math
from datetime import datetime
from sklearn.ensemble import RandomForestRegressor
import xgboost
eps = 1e-6
def getMH (x): # get normalised time from time
// Problem Description: Find which edge to remove and add so as to minimise the number of hops to travel between flights.
// It is clear that the edge we remove has to be on the longest path on the original
// tree (otherwise we cannot make the longest path shorter). The question is which edge is to be
// removed and which edge is to be added. We can consider which edge to be added first. After
// removing one edge, the tree become two trees. The edge to be added is the one that connects
// the centers of the longest paths of the two subtrees. Because the longest paths of the two
// subtrees can always yield some long path after we add the edge. The best way is to split
// them into halves. Having this in mind, we can brute-force here - try to remove every edge
// on the original longest path and add the new edges respectively.
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
map<string, int> L;
int main()
{
#include<iostream>
#include<string>
using namespace std;
struct node
{
char info;
node *left;
node *right;
};
long long pre;
/*This problem asks us to find all possible paths which form the diameter of the given tree.
So first we do a BFS/DFS from any vertex uu, and find the vertex xx which is farthest from ss.
Note xx must be an end of a longest path. Then, we do another BFS/DFS traversal from xx to
find all vertices {s}{s}which are farthest from xx. Every single vertex here, including xx,
is one worst root, and the mid point, or points if the length is even, of every single path
is/are the best roots. After that, we need to do a third traversal from any vertex in {s}
to find any remaining worst roots which are close to xx, and so were not discovered by our
second traversal.*/
#include <bits/stdc++.h>