This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pos_w = 1/mean(train_tmp$target) | |
w = ifelse(train_tmp$target == 0, 1, pos_w) | |
w = w/sum(w) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
insertion_sort <- function(line) | |
{ | |
for(i in 2:length(line)) | |
{ | |
k <- i-1 | |
tmp <- line[i] | |
while(k > 0 && line[k] > tmp) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N, D = map(int, input().split()) | |
rate = [int(x) for x in input().split()] | |
for _ in range(D): | |
prof1 = int(input()) | |
d = {} # this has indexes | |
d1 = {} ## this has index difference | |
for i in range(len(rate)): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## https://www.hackerrank.com/contests/morgan-stanley-codeathon-2017/challenges/shell-sort-command | |
n = int(input()) | |
strs = [input().split() for x in range(n)] | |
count_space = len([item for sublist in strs for item in sublist])/ len(strs) | |
key, reverse_flag, c_type = input().split() | |
## set type first |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
damn <- function(x) ## x should be a vector | |
{ | |
p <- list() | |
for(j in x) | |
{ | |
out <- tryCatch({ | |
if(j %% 2 == 0) p <- append(p, j) | |
else p <- append(p, 101) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enter your code here. Read input from STDIN. Print output to STDOUT | |
T = int(raw_input()) | |
sell = [[] for i in range(100)] | |
product_sell = [[[] for j in range(10)] for i in range(100)] | |
state_sell = [[[] for j in range(7)] for i in range(100)] | |
p_s_sell = [[[[] for j in range(7)] for j in range(10)] for i in range(100)] | |
for t in range(T): | |
query = 0 | |
data = raw_input().split() | |
if data[0] == 'S': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstring> | |
using namespace std; | |
void parseDot(char s[100], int &first, int &second) { | |
int length = strlen(s); | |
int temp = 0, dotFound = 0, negative = 1; | |
for (int i = 0; i < length; i++) { | |
if (s[i] == '.') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path <- "/home/manish/Desktop/temp" | |
setwd(path) | |
library(data.table) | |
library(lubridate) | |
library(tidytext) | |
saleData <- fread("new_data/final_model_data.txt") | |
head(saleData) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate_ndcg(test_movies, predicted_movies, already_watched): | |
partial_dcgs = [] | |
predicted_event_flags = {} | |
actual_events = test_movies | |
for pred_index, predicted_event in enumerate(predicted_movies): | |
try: | |
last_occ = predicted_event_flags.get(predicted_event, -1) | |
actual_index = actual_events[last_occ+1:].index(predicted_event) | |
effective_index = actual_index + last_occ + 1 | |
predicted_event_flags[predicted_event] = effective_index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
strn = 'abcbaabbcc' | |
d = {} | |
k = 2 | |
prev_word = strn[0] | |
c = 1 | |
for s in strn[1:]: | |
if prev_word == s: | |
c+=1 | |
print('this is c = {} in first loop'.format(c)) |