Skip to content

Instantly share code, notes, and snippets.

@fitomad fitomad/double_ml.py
Created Jan 19, 2018

Embed
What would you like to do?
Modelo que predice el doble de un valor dado. Usan progresión lineal para la predicción
from sklearn.linear_model import LinearRegression
# N veces
X_train = [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]
# Resultado
y_train = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
model = LinearRegression()
model.fit(X_train, y_train)
# Convertimos y guardamos el modelo
# de scikit-learn
import coremltools
coreml_model = coremltools.converters.sklearn.convert(model, ["multiplicador"], "resultado")
# Metadatos del modelo
coreml_model.author = 'Adolfo Vera'
coreml_model.license = 'BSD'
coreml_model.short_description = 'Predice el doble de un valor entero'
# Descripcion de los parametros de entrada
coreml_model.input_description['multiplicador'] = 'El valor del que queremos predecir el doble'
# Descripcion de los parametros de salida
coreml_model.output_description['resultado'] = 'El doble'
coreml_model.save('TablaModel.mlmodel')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.