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
import numpy as np | |
import random | |
def gradient_descent(alpha, x, y, ep=0.0001, max_iter=10000): | |
converged = False | |
iter = 0 | |
m = x.shape[0] # number of samples | |
# initial theta |
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//Desktop/MLC01/" | |
setwd(path) | |
# Load data and libraries ------------------------------------------------- | |
library(data.table) | |
library(h2o) | |
library(caret) | |
library(stringr) | |
library(e1071) |
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
library(data.table) | |
library(jsonlite) | |
library(purrr) | |
library(RecordLinkage) | |
library(stringr) | |
library(tm) | |
traind <- fromJSON("train.json") | |
test <- fromJSON("test.json") |
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
library(data.table) | |
library(jsonlite) | |
#### Train | |
train <- fromJSON("train_data.json") | |
train_data <- data.table(ID = unlist(names(train))) | |
train_data[, `:=` (genres = unlist(lapply(train, '[',1)), | |
titles = unlist(lapply(train, '[',2)), |
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
# coding: utf-8 | |
import json | |
import pandas as pd | |
file_name_1 = "train_data.json" | |
with open(file_name_1, 'r') as jsonfile1: | |
data_dict_1 = json.load(jsonfile1) | |
file_name_2 = "test_data.json" | |
with open(file_name_2, 'r') as jsonfile2: |
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
table_1 = pd.DataFrame({'Slab_ID': np.repeat('1_1',19), 'ActCastLength':np.arange(1.1,3,0.1)}) | |
table_2 = pd.DataFrame({'Slab_ID': ['1_1','1_1'], 'DefectStart_Y':[1.5,2.3],\ | |
'DefectEnd_Y':[1.8,2.5], 'Defective':[1,1]}) | |
for c in np.arange(2): | |
table_1['Defective' + str(c)] = table_1['ActCastLength'].between(table_2.loc[c,'DefectStart_Y'],\ | |
table_2.loc[c, 'DefectEnd_Y']) | |
table_1['Defective' + str(c)] = [1 if x == True else 0 for x in table_1['Defective'+str(c)]] | |
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
library(data.table) | |
sdata <- fread("address_data.csv") | |
head(sdata) | |
setnames(sdata,"x","address") | |
# some cleaning | |
sdata$pincodes := unlist(regmatches(address, gregexpr("(\\d+){6}",sdata$address)))] | |
sdata$address := gsub(pattern = "(\\d+){6}",replacement = "", x = sdata$address)] |
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
# coding: utf-8 | |
# load libary - you might need to install xlrd library in case it throws any error in reading file | |
import pandas as pd | |
# read file | |
sensor = pd.read_excel("SENSOR-009.xlsx",sheetname="Sheet1") |
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
#!/usr/bin/env python | |
import csv | |
import json | |
import sys | |
import numpy as np | |
LOCAL = True |
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)) |
OlderNewer