Uploading the nonlinear data to Redshift

We first need to create the table that will host the data. We will call that table nonlinear. It only has three columns: an index, the predictor X, and the outcome y:

CREATE TABLE IF NOT EXISTS nonlinear (  id integer primary key,  x1 real,  y real);

Once the table is created, we can upload the CSV file to S3, connect to the database, and import the data in the non-linear table with the command:

copy nonlinear from 's3://aml.packt/data/ch9/nonlinear.csv' CREDENTIALS 'aws_access_key_id=<access key id>;aws_secret_access_key=<access secret key>' CSV;

We can verify that the nonlinear table now has a thousand rows with the query:

$ psql $REDSHIFT_CONNECT -c "select count(*) from nonlinear" > count> 1000 ...

Get Effective Amazon Machine Learning now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.