Skip to content

Instantly share code, notes, and snippets.

@pjankiewicz
Created March 1, 2019 20:04
Show Gist options
  • Save pjankiewicz/b0395de69c1db9bfaf7b85013fe2ca9c to your computer and use it in GitHub Desktop.
Save pjankiewicz/b0395de69c1db9bfaf7b85013fe2ca9c to your computer and use it in GitHub Desktop.
Ludwig model
import numpy as np
import pandas as pd
from ludwig import LudwigModel
from sklearn.model_selection import train_test_split
df = pd.read_csv("input/train.tsv", sep="\t")
df["log_price"] = np.log1p(df["price"])
model = LudwigModel({
"input_features": [
{"name": "name", "type": "text"},
{"name": "category_name", "type": "text"},
{"name": "brand_name", "type": "text"},
{"name": "item_description", "type": "text"},
{"name": "shipping", "type": "category"},
{"name": "item_condition_id", "type": "category"},
],
"output_features": [
{"name": "log_price", "type": "numerical"}
]
})
train, test = train_test_split(df, random_state=0)
model.train(train)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment