Skip to content

Instantly share code, notes, and snippets.

View necronet's full-sized avatar
👨‍💻
Hello old friend!

Jose Ayerdis necronet

👨‍💻
Hello old friend!
View GitHub Profile
@necronet
necronet / lambda_selection_glmnet.R
Created June 18, 2020 04:26
Quick gist to show lambda selection difference between explicit and heuristic
library(glmnet)
x_var <- data.matrix(mtcars[, c("hp", "wt", "drat")])
y_var <- mtcars[, "mpg"]
fit_lambda_specified <- cv.glmnet(x_var, y_var, alpha = 0, lambda = 10^seq(5, -5, by = -.1))
fit_lambda_automatic <- cv.glmnet(x_var, y_var, alpha = 0)
plot(fit_lambda_specified, xvar="lambda")
plot(fit_lambda_automatic, xvar="lambda")
@necronet
necronet / spacyr_bug.R
Created June 5, 2020 17:19
Spacy R crashes on tokenizer
corpus <- readr::read_csv("corpus.csv")
# Work with
#t <- corpus$text[1:100]
t <- corpus$text[124]
spacyr::spacy_tokenize(t)
@necronet
necronet / corpus.csv
Created June 5, 2020 17:18
spacyr crash on tokenizer
We can't make this file beautiful and searchable because it's too large.
text,label
Stuning even for the non-gamer: This sound track was beautiful! It paints the senery in your mind so well I would recomend it even to people who hate video game music! I have played the game Chrono Cross but out of all of the games I have ever played it has the best music! It backs away from crude keyboarding and takes a fresher step with grate guitars and soulful orchestras. It would impress anyone who cares to listen! ^_^,__label__2
" The best soundtrack ever to anything.: I'm reading a lot of reviews saying that this is the best 'game soundtrack' and I figured that I'd write a review to disagree a bit. This in my opinino is Yasunori Mitsuda's ultimate masterpiece. The music is timeless and I'm been listening to it for years now and its beauty simply refuses to fade.The price tag on this is pretty staggering I must say, but if you are going to buy any cd for this much money, this is the only one that I feel would be worth every penny.",__label__2
" Amazing!: This soundtrack is my favorite musi
@necronet
necronet / gradient_background_ggplot2.R
Created June 4, 2020 17:40
On Adding a custom gradient w/ background layer to ggplot
g <- rasterGrob(greens, width = unit(1, "npc"), height = unit(1, "npc"), interpolate = TRUE)
test <- ggplot(mtcars, aes(x = mtcars$hp, y = mtcars$mpg)) +
theme(plot.background = element_blank(),
panel.background = element_blank()) +
annotation_custom(
grob = g, xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf
) + geom_point()
plot_grid(test, labels = c('A'))
@necronet
necronet / bagging.R
Created August 7, 2019 23:14
Create multiple bagging trees and capture each RSME in order to graph the reduce in variance
errors <- vector()
for ( i in seq(from = 1, to = 50) ) {
print(paste('Bagging with',i,'trees'))
ames_bag_i <- bagging( formula = Sale_Price ~ ., data=ames_training, nbagg = i, control = rpart.control(minsplit = 2, cp = 0))
errors <- c(errors, ames_bag_i$err)
}
error_df <- as.data.frame(errors)
error_df$n_trees <- 1:nrow(error_df)
ggplot(data = error_df, aes(x = n_trees, y = errors)) + geom_line()
@necronet
necronet / slice_sample.py
Created October 18, 2018 22:26
Working with slice
# A example on how to use slice in tensorflow, simple but important to remember.
import tensorflow as tf
x = tf.constant([[[1., 2.], [3., 4. ], [5. , 6. ]],
[[7., 8.], [9., 10.], [11., 12.]]])
# All first elements
# [[[ 1.],[ 3.],[ 5.]], [[ 7.],[ 9.],[11.]]]
res = tf.slice(x, [0, 0, 0], [2, 3, 1])
@necronet
necronet / gitignore-drupal
Created November 20, 2013 08:04
Archivo gitignore para drupal
#Ignore sass cache
.sass-cache/
#ignore tmp
tmp/
sites/all/default/files/*
#Ignore CSS files from theme (they all autogenerated from sass)
sites/all/themes/ayerdis/css/*
@necronet
necronet / crawler.py
Created February 13, 2016 07:49
Sample of gist
import requests
import re
from bs4 import BeautifulSoup
#<a href="salud-mental/" class="boton">Ver reportaje</a>
#http://multimedia.laprensa.com.ni/
def trade_spider(max_pagina):
pagina=1;
while pagina <=max_pagina:
url='http://multimedia.laprensa.com.ni/index.html'
crap= requests.get(url)
<string-array name="currencies" translatable="false">
<item name="USD">Dollar - $</item>
<item name="MXN">Mexico Peso - $</item>
<item name="COP">Colombian Peso - $</item>
<item name="ARS">Argentine Peso - $</item>
<item name="NIO">Cordoba - C$</item>
<item name="GTQ">Quetzales - Q</item>
<item name="CRC">Colones - ₡</item>
<item name="HNL">Lempira - L</item>
<item name="EUR">Euro - €</item>
final class PrintDialogJavaScriptInterface {
public String getType() {
return cloudPrintIntent.getType();
}
public String getTitle() {
return cloudPrintIntent.getExtras().getString("title");
}
public String getContent() {