View rf_python.py
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
# gist only to keep record from https://www.jiqizhixin.com/articles/bb59b879-e030-400d-abbc-d9c0708266ff | |
# Random Forest Algorithm on Sonar Dataset | |
from random import seed | |
from random import randrange | |
from csv import reader | |
from math import sqrt | |
# Load a CSV file | |
def load_csv(filename): |
View coverIntervals.py
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
# list_forecasts = [[1,3],[2,5]] | |
## cover(1pm, 7pm, [[1,3], [5,7]]) | |
## return [[3,5]] | |
def cover(startTime, endTime, list_forecasts): | |
n = len(list_forecasts) | |
View plot_gly_on_map.R
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
plot_gly_on_map <- function(newDF, global = FALSE, trend = FALSE, outputFile = "test.png"){ | |
# newDF$value <- newDF$summerSum_UHY - newDF$springSum_UHY | |
longRange <- range(newDF$Long) | |
latRange <- range(newDF$Lat) | |
bbox <- make_bbox(longRange,latRange,f = 0.3) | |
# myMap <- get_map(location=bbox, source="stamn",crop=TRUE,color="bw",maptype="terrain") | |
myMap <- get_map(location = bbox, maptype="toner-lite", source="stamen",zoom=7,color = "bw",crop=TRUE) | |
# ggmap(myMap) | |
SU_locations <- unique(newDF[,c("Station","Lat","Long")]) |
View omnioutliner
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
-- LaunchBar Action Script | |
-- apple script to append launchbar input to the last line of omnioutliner | |
on handle_string(_string) | |
tell application "OmniOutliner 4.6.1" | |
set theDocument to the front document | |
set newRow to make new row at last row of front document | |
set topic of newRow to _string | |
outdent newRow |
View k_means.py
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
# This is a pure python K-means implementation | |
import numpy as np | |
def calDistance(x,y): | |
# return the distance of x and y | |
return np.sum((x-y)**2) | |
def assignClusters(centers,data): | |
distance = np.zeros((len(data),len(centers))) |
View classfication_method.R
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
## Classification starts now | |
library(MASS) | |
library(e1071) | |
library(rda) | |
#################################### | |
qda.model=function(traindata){ | |
qda.result=qda(Y~.,data=traindata) | |
return(qda.result) | |
} |
View classifier.R
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
randomForest_clf <- function(matTrain,trainLabel,matTest,...){ | |
library(randomForest) | |
rf_model<-randomForest(matTrain,trainLabel,ntree=500) | |
rf_predict<-predict(rf_model,matTest) | |
return(rf_predict) | |
} | |
xgboost_clf_1000 <- function(matTrain,trainLabel,matTest,...){ | |
library(xgboost) |
View ts_seg.py
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 | |
def slidingWindow(x,max_error): | |
n=len(x) | |
leftNode=0 | |
segmentList=[] | |
print n | |
while leftNode<n-1: | |
print leftNode |
View onlineClf.py
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
from __future__ import division | |
import numpy as np | |
class OnlineClf(object): | |
def __init__(self,iterNum,R): | |
self.w=None | |
self.iterNum=iterNum | |
self.misNum=[[0,0]] |
NewerOlder