TannerGilbert / Tutorials

Code for some of my articles
https://gilberttanner.com/
MIT License
561 stars 631 forks source link

Error in importing the ludwig module. #37

Closed Samar-080301 closed 3 years ago

Samar-080301 commented 3 years ago

Describe the bug There is a little syntax error, that's causing traceback. The bug is that LudwigModel not found in ludwig And line no. 19 is causing ValueError: At least one between dataset and training_set must be not None To Reproduce Steps to reproduce the behavior:

  1. Run Tutorials\Uber Ludwig Introduction\python_exmple.py
  2. See error

Expected behavior It should run seamlessly but there are some errors

Desktop (please complete the following information):

Additional context Can I please rectify the errors?

Samar-080301 commented 3 years ago

@TannerGilbert Please look into the issue. Thank You!

TannerGilbert commented 3 years ago

The code changed with the newest version of Ludwig (0.3):

Correct code:

from ludwig.api import LudwigModel
import pandas as pd

df = pd.read_csv('Tweets.csv')
print(df.head())

model_definition = {
    'input_features':[
        {'name':'text', 'type':'text'},
    ],
    'output_features': [
        {'name': 'airline_sentiment', 'type': 'category'}
    ]
}

print('creating model')
model = LudwigModel(model_definition)
print('training model')
train_stats, _, _ = model.train(dataset=df)

I'll try to update all the code the upcoming days

TannerGilbert commented 3 years ago

I just updated the code and article to work with the newest version of Uber Ludwig.