Back to Community
Pass Training Data from MySQL table as Tuples in Python Variable

Hi everyone. I'm a student who is interested in Machine Learning field.
right now I'm making a web-based application that applies Logistic Regression to classify tweets into 4 topics: health, music, sport and technology.
I stored 6000 tweets into MySQL table named trainingtweets that consist of 3 column (username, tweets, label) and use it as training data.
now I want to pass all data from column tweets and label from the trainingtweets to a variable so I can train my classifier using the variable.

here's the code I have created:

import pandas as pd  
from sqlalchemy import *



#Connect to database and get the data  
engine = create_engine('mysql+mysqlconnector://root:[email protected]:3306/machinelearning')  
tweet = pd.read_sql_query('SELECT label, tweets FROM trainingtweets', engine)  
etweet = pd.read_sql_query('SELECT tweet, label FROM evaluatetweets', engine)

reviews = [(list(tweet.tweets), label)  
           for label in tweet.label  
           for tweets in tweet.tweets(label)]

train = reviews[0:100]

print(train[0])  

when I run the code above, it gives me error:
Traceback (most recent call last): File "C:/Users/Indra/PycharmProjects/TextClassifier/textblobclassifier.py", line 12, in <module> for label in tweet.label File "C:/Users/Indra/PycharmProjects/TextClassifier/textblobclassifier.py", line 13, in <listcomp> for tweets in tweet.tweets(label)] TypeError: 'Series' object is not callable

I'm using SQLAlchemy as the database engine and Pandas to read the data from database table.
can anyone help me solving this problem? any help would be really appreciated.