Created
March 1, 2019 20:04
-
-
Save pjankiewicz/b0395de69c1db9bfaf7b85013fe2ca9c to your computer and use it in GitHub Desktop.
Ludwig model
This file contains 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
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