Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function index()
- {
- $this->load->model("regression_model") ;
- $array = $this->regression_model->display_data();
- $targets = $this->regression_model->display_data2();
- $matrix = new Matrix($array);
- $set = new Set($targets);
- $arraytrix = $matrix->toArray();
- $arrayset = $set->toArray();
- $col[] = array_column($arraytrix, 'year');
- $col2[] = array_column($arrayset, 'total');
- var_dump($col);
- var_dump($col2);
- $regression = new LeastSquares();
- $regression->train($col, $col2);
- $predicted = $regression->predict([2018]);
- var_dump($predicted);
- $this->load->view('regression');
- }
- function display_data()
- {
- $query1 = $this->db->query("SELECT year from total_year");
- return $query1->result_array();
- }
- function display_data2()
- {
- $query1 = $this->db->query("SELECT total from total_year");
- return $query1->result_array();
- }
Add Comment
Please, Sign In to add comment