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
/* | |
* AddressSanitizerExampleUseAfterScope.cpp | |
* | |
* Created on: Jun 7, 2017 | |
* Author: pedro | |
*/ | |
#include <iostream> | |
#include <cmath> | |
#include <vector> | |
#include <chrono> |
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
//============================================================================ | |
// Name : AddressSanitizer.cpp | |
// Author : Pedro Valiente Verde | |
// Version : | |
// Copyright : Your copyright notice | |
// Description : Hello World in C++, Ansi-style | |
//============================================================================ | |
#include <iostream> | |
#include <chrono> |
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
class IInstrumento{ | |
public: | |
virtual void Tocar()=0; | |
virtual ~IInstrumento()=default; | |
}; | |
class IPercusion:virtual public IInstrumento{ | |
public: | |
//Metodos propios de los instrumentos de Percusion | |
}; |
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
#include <iostream> | |
#include <memory> | |
class IBase{ | |
public: | |
virtual int GetX() const=0; | |
virtual int GetY() const=0; | |
virtual ~IBase()=default; | |
}; |
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
template<typename T> | |
class WrapperVector: public std::vector<T> { | |
public: | |
typedef std::vector<T> Vector; | |
typedef std::function<bool(T)> Filtro; | |
typedef boost::filter_iterator<Filtro, typename Vector::iterator> IteradorFiltro; | |
WrapperVector(const Vector &valores, Filtro filtro) : | |
Vector(valores), filtro(filtro) { | |
} |
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
class Domicilio { | |
public: | |
Domicilio(int codigo_postal, int huespedes, std::string informacion = ""); | |
~Domicilio() = default; | |
/** | |
* Getters y setters de atributos | |
*/ | |
int CodigoPostal() const; | |
int Huespedes() const; | |
void Informacion(const std::string &informacion); |
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
class ContentBased(object): | |
""" | |
Modelo de recomendación de articulos basados en tags. | |
El modelo vectoriza cada articulo para poder calcular la similitud. | |
""" | |
def __init__(self, stop_words=None, token_pattern=None, metric='cosine', n_neighbors=5): | |
if stop_words is None: | |
stop_words = stopwords.words("english") | |
if token_pattern is None: |
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
from pyspark.sql import SQLContext | |
from pyspark import SparkConf, SparkContext | |
from pyspark.ml.recommendation import ALS | |
from pyspark.ml.tuning import CrossValidator, ParamGridBuilder | |
from pyspark.ml.evaluation import RegressionEvaluator | |
from math import sqrt | |
from operator import add | |
conf = (SparkConf() |
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 wrapper_logistic_regression_with_L2(l2_penalty, | |
feature_matrix=feature_matrix_train, | |
sentiment=sentiment_train, | |
initial_coefficients=np.zeros(194), | |
step_size=5e-6, max_iter=501): | |
coef=logistic_regression_with_L2(feature_matrix, sentiment, initial_coefficients, step_size, l2_penalty, max_iter) | |
return (l2_penalty,coef) | |
from multiprocessing import Pool |
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 minimizar(optimizador, funcion_coste, acumulador, learning_rate_iniciaL_tf, rate_momemtum_tf): | |
grads_and_vars = optimizador.compute_gradients(funcion_coste) | |
gradientes,variables = [],[] | |
for grad, var in grads_and_vars: | |
variables.append(var) | |
if grad is None: | |
gradientes.append(grad) | |
continue | |
# accumulador = accumulador * momentum + gradiente |
NewerOlder