.

regression: a data analysis api
from scideas software

.

regression api PHP code example

.

The csv file

.

The code

//your regression api key $key = "abcxyz"; //your prepared csv file $file = "insurance.csv"; //read the csv file into an array of data rows $handle = fopen($file, "r"); $data = []; if ($handle) { while (($line = fgets($handle)) !== false) { $data[] = trim($line); } fclose($handle); } //your POST fields $p['key'] = $key; $p['outcome_variable'] = "charges"; $p['ignore_variables'] = ['sex']; //no date field in the csv //$p['convert_date_to'] = "month"; $p['data'] = $data; //the regression api endpoint $url = "https://services.scideas.net/regression/api"; //encode payload array as JSON $postData = json_encode($p); //create php curl command $ch = curl_init(); //set curl parameters curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch,CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // $output=curl_exec($ch); if ($output === false) { $output = curl_error($ch) . " " .curl_errno($ch); } curl_close($ch); //display output var_dump($output); Or as curl command
curl -X POST -L -H "Content-Type: application/json" -d "{\"key\":\"abc123\",\"outcome_variable\":\"charges\",\"ignore_variables\":[\"sex\"],\"data\":[\"age,sex,bmi,children,smoker,region,charges\",\"19,female,27.9,0,yes,southwest,16884.924\",\"18,male,33.77,1,no,southeast,1725.5523\",\"28,male,33,3,no,southeast,4449.462\",\"33,male,22.705,0,no,northwest,21984.47061\",\"32,male,28.88,0,no,northwest,3866.8552\"]}" https://services.scideas.net/regression/api
.

The result



Test mode