Skip to content

Instantly share code, notes, and snippets.

View myrddian's full-sized avatar
🏠
Working from home

Enzo Reyes myrddian

🏠
Working from home
  • Melbourne Australia
View GitHub Profile
#Mock Classes that simulate a Pandas frame
class loc_class:
def __init__(self):
self.rows = []
self.csv_df = None
def add_row(self, item):
self.rows.append(item)
library(mvtnorm)
library(ggplot2)
library(MCMCpack)
expected_task <- list(mean=3,sd=2)
hyper_parameters <- list(alpha=1, beta=1)
data_samples = rnorm(100,6,3)
random_samples <- rnorm(100,20,5)
find_likelyhood <- function(target_model, target) {
library(MCMCpack)
example_prior <- list(mean=3,sd=2)
hyper_parameters <- list(alpha=1, beta=1)
data_samples = rnorm(100,6,3)
random_samples <- rnorm(100,20,5)
find_likelyhood <- function(target_model, target) {
return(dnorm(target,target_model$mean, target_model$sd))
}
excel_file = 'excel.xlsx'
out_file = 'excel.csv'
#External Global variables
__col_size__ = 14
__i_start__ = 6
__c_size__ = 202
"""Read the country file and parse its contents"""
def read_country_data(xls_file, country_size, index_start, output_file, col_size):
print('Conversion Starting')
@myrddian
myrddian / xml2json.py
Created November 18, 2018 11:28
Example conversion of XML to JSON
import json
import io
from lxml import etree
def read_xml(file_name):
in_file = open(file_name,"rb")
xml_file = etree.parse(in_file)
return xml_file
def generate_rterms_dic(xml_element):
@myrddian
myrddian / random_dirichlet .R
Last active September 29, 2018 06:05
Generates a random dirichlet with n-attributes
#returns a randomly generated dirichlet for psuedo counts
#Alpha is passed as Shape to the RGamma Function
#Beta is passed as scale to the RGamma Function
#NVar is the number of variables you are going to psuedocount
random_dirichlet <- function(n_var, alpha=0, beta=1) {
return_val <- 0
#Prevent alpha being less than n_var other wise
#n_var will have empty psuedo-counts, which is what
@myrddian
myrddian / A2.R
Created September 29, 2018 04:38
#returns a randomly generated dirichlet
random_dirichlet <- function(n_var, alpha, beta) {
return_val <- 0
for(i in 1:n_var) {
return_val[i] <- rgamma(1,shape=alpha,scale = beta)
}
#Normalise and round to a nice values
return_val <- round(return_val/sum(return_val) * 100,1)/100
model.analysis <-function(test_res, predict_rsp) {
col_names <- c("TruePositive","FalsePositive",
"FalseNegative","Accuracy","Precision","Recall","F1")
ret_val <- data.frame(matrix(ncol = length(col_names), nrow = 0))
colnames(ret_val) <- col_names
ret_val[nrow(ret_val) + 1,] = c(tp,fp,fn,accuracy,precision,recall,f1)
return(ret_val)
}