Train

Install the Tangram CLI

If you haven't already, install the Tangram CLI.

Get the data

download heart_disease.csv

The heart disease dataset contains information from cardiac patients such as their age, cholesterol, and stress test results. Below are some example rows.

agegenderchest_painresting_blood_pressurecholesterolfasting_blood_sugarresting_ecg_resultexercise_max_heart_rateexercise_induced_anginaexercise_st_depressionexercise_st_slopefluoroscopy_vessels_coloredthaldiagnosis
63maletypical angina145233trueprobable or definite left ventricular hypertrophy150no2.3downsloping0.0fixed defectNegative
67maleasymptomatic160286falseprobable or definite left ventricular hypertrophy108yes1.5flat3.0normalPositive
67maleasymptomatic120229falseprobable or definite left ventricular hypertrophy129yes2.6flat2.0reversible defectPositive

The last column, called diagnosis, is either Positive if the patient has heart disease or Negative if they don’t.

Train

We can train a model to predict the diagnosis column using the tangram train command, passing in the path to the CSV file and the name of the column we want to predict, called the target column.

$ tangram train --file heart_disease.csv --target diagnosis

The CLI automatically transforms the data into features, trains a number of models to predict the target column, and writes the best model to a .tangram file. We can use this file to make predictions from our code.