This file contains hidden or 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
| # I got this working with code from https://datascienceplus.com/random-forests-in-r/ | |
| # It is an excelent resource! | |
| set.seed(50) | |
| bikeperday <- read.csv('Bike-Sharing-Dataset/day.csv') | |
| # Calculate sample | |
| sample <- sample.int(n = nrow(bikeperday), | |
| size = floor(.75 * nrow(bikeperday)), | |
| replace = F) |
This file contains hidden or 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/env ruby | |
| def derivative_of(f:, x:) | |
| h = 1e-14 # 1 * 10^-14 this is the smallest number ruby can handle in calculations before defaulting result to zero. | |
| (f.call(x + h) - f.call(x)) / h # This is a naive approach to calculate limit of f(x) in x. | |
| end | |
| # Newton's Method, where we calculate f(x), f'(x) and calculate error. | |
| def find_root(f:, seed:, iterations: nil, error_level: nil) |
This file contains hidden or 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 x_sub(index, lower, h) | |
| x_k = lower + (index * h) | |
| end | |
| def booles_rule(lower, upper, &block) | |
| h = (upper - lower) / 4.0 | |
| sum = 0 | |
| sum += 7 * yield(lower) | |
| sum += 32 * yield(x_sub(1, lower, h)) |
We can't make this file beautiful and searchable because it's too large.
This file contains hidden or 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
| RADICADO,FECHA,HORA,DÍA DE LA SEMANA,CLASE DE VEHICULO,TIPO DE SERVICIO,TIPO DE VICTIMA,SEXO,ESTADO DE BEODEZ,RESULTADO DE BEODEZ,GRAVEDAD,CLASE DE ACCIDENTE,CAUSA,DIRECCIÓN,BARRIO,AREA,Coordenadas | |
| 2181714,06/30/2018,2:55 p.m.,sábado,TRACTOCAMION,PUBLICO,Conductor,Masculino,No,N/A,SOLO DAÑOS,Choque,No mantener distancia de seguridad,Carrera 48 Calle 50 Sur,LAS VEGAS,Urbana, | |
| 2181733,06/30/2018,9:50 a.m.,sábado,BUS,PUBLICO,Conductor,Masculino,No,N/A,SOLO DAÑOS,Choque,Desobedecer senales,Carrera 50 Calle 46 Sur,LAS VEGAS,Urbana,"(6.16131219, -75.603198185)" | |
| 2181733,06/30/2018,9:50 a.m.,sábado,AUTOMOVIL,PARTICULAR,Conductor,Masculino,No,N/A,SOLO DAÑOS,Choque,Desobedecer senales,Carrera 50 Calle 46 Sur,LAS VEGAS,Urbana,"(6.16131219, -75.603198185)" | |
| 2181717,06/30/2018,10:45 p.m.,sábado,MOTOCICLETA,PARTICULAR,Motociclista,Masculino,No,N/A,SOLO DAÑOS,Choque,Desobedecer senales,Calle 37 Sur Carrera 36,MESA,Urbana,"(6.168044613, -75.583236971)" | |
| 2181717,06/30/2018,10:45 p.m.,sábado,AUTOMOVIL,PARTICULAR,Conductor,Mas |
This file contains hidden or 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
| /* | |
| * CSS chat | |
| */ | |
| body { | |
| top: 0; | |
| left: 0; | |
| background-color: #caccd1; | |
| margin-left: 35%; | |
| margin-right: 35%; |
This file contains hidden or 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
| source 'https://rubygems.org' | |
| gem 'faker' |
This file contains hidden or 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
| defmodule Distances do | |
| def euclidean(a, b) when length(a) > 0 and length(b) > 0 and length(a) == length(b) do | |
| # We zip both lists into one, then we reduce it to the euclidean calculation. | |
| # Enum.zip_reduce(a, b, 0, fn) <- as a shortcut. | |
| Stream.zip(a, b) | |
| |> Enum.reduce(0, fn {x, y}, accumulator -> | |
| accumulator + (x - y) ** 2 | |
| end) | |
| |> :math.sqrt() | |
| end |
OlderNewer