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 code is from https://www.cac.cornell.edu/VW/OpenMP/whileloop.aspx | |
#include <omp.h> | |
#include <stdio.h> | |
int main(int argc, char **argv) | |
{ | |
/* OpenMP does not provide a parallel while loop, | |
so we're going to have to make one ourselves... */ | |
int sj, sstop, tn, tj, tstop; | |
int foo(int j); |
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; | |
import matplotlib.pyplot as plt | |
import warnings | |
# Ref: http://practicalcryptography.com/miscellaneous/machine-learning/guide-mel-frequency-cepstral-coefficients-mfccs/ | |
# Ref2:http://python-speech-features.readthedocs.org/en/latest/. However, I checked the library code and found there might be a mistake when using rfft | |
def preemphasis(signal,coeff=0.95): | |
return numpy.append(signal[0],signal[1:]-coeff*signal[:-1]) |
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): |
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) | |
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")]) |
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 |
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))) |
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) | |
} |
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) |
NewerOlder