0

I had a term project that needs to use data stored in MySQL to train a classification model using Tensorflow or whatever else.

I've tried to use examples from https://github.com/tensorflow/docs/blob/master/site/en/r2/tutorials/keras/feature_columns.ipynb, and it took me a lot of time to process the data to a csv file and modify the python script. While I need to do a lot of experiments, is there may be much more simple tool for me to train and experiment on my MySQL dataset?

wuyi
  • 53
  • 6

2 Answers2

1

Maybe SQLFlow can meet your needs; I tried to build an SQLFlow script with the dataset you provided, she should be like this:

SELECT *
FROM Heart_Disease
TRAIN DNNClassifier /* a pre-defined TensorFlow estimator, tf.estimator.DNNClassifier */
WITH n_classes = 3, hidden_units = [10, 20]  /* a parameter of the Estimator class constructor */
COLUMN Age, Sex, CP, FBS ..  /* From the raw data, enter the columns that you think will help predict your heart rate. */
LABEL Target  /* lable column */
INTO Heart_Disease.test_model; /* The trained model is saved to the specified data table */

It is also very easy to apply this model:

SELECT *
FROM Heart_Disease.predict
PREDICT Heart_Disease.predict_result.Target
USING Heart_Disease.test_model;

Heart_Disease.predict Target column is empty, The predicted Target is saved to the Heart_Disease.predict_result.Target table.

FYI:https://github.com/sql-machine-learning/sqlflow/blob/develop/doc/demo.md

This is my first answer. Hope I can help you.

llxxxll
  • 36
  • 1
  • That's a great tool, thought it could be good if I can write SQL and generate the code for me. – wuyi May 22 '19 at 04:00
0

What you I think can do, is get the dump of data from sql if it's not realtime and not getting updated and then use that dump for the rest, or you can create a connection of mysql and then feed that connection into pandas read_sql function, to get the dataframe. A way to do that

Also if you're new to tensorflow, you should try looking at the tensorflow's estimator API that shall do your work, Apart from that you may use tensorflow's keras wrapper that also eases the work of making a NN network.

Community
  • 1
  • 1
Saurav Joshi
  • 414
  • 5
  • 13