- Linear Regression
- File processing (.txt format)
Calculate the linear regression parameters that minimize the total square err error of the approach
- Accepts as program parameters a list of files.
- Each file contains at least 3 lines.
- The data are numbered from position 0
- The cases of vertical and horizontal vectors are also taken into account (test files 4h, 5h)
num1:num2
where num1 => X
num2 => Y
Sample of a test file
10.7:15.6
5.6:20.5
3.5:15.4
2.4:10.3
1.3:6.2
8.2:10.1
9.1:25
In the general case, parameters and output are decimal numbers with 2 decimal digits. (if decimal places are needed)
FILE: input1, a=5.31 b=2.32 c=1 err=1340.32
FILE: input2, a=-2.31 b=1.23 c=1 err=13.25
FILE: input3, a=0 b=3 c=1 err=0
where input1 => file name #1
etc
Calculate scores of teams and points. The teams must be ordered based on scores. In tie, ascending order to name. A win gives 3 points, a win gives 3 points, the tie gives 1 point and a loss gives 0 points.
Team1-Team2: Score1-Score2
Portugal-Greece:1-2
Greece-Spain:2-1
1. Portugal 6 3-2
2. Greece 4 4-4
3. Spain 4 2-2
- Open terminal and create a Bash file
$ touch regr.sh
$ touch results.sh
- Open your script and add the following commands
#!/bin/bash
-
Save and close
-
Set executable permissions
$ chmod u+x regr.sh
$ chmod u+x results.sh
- Run executable scripts
$ ./regr.sh
$ ./results.sh
or
$ bash regr.sh
$ bash results.sh
or
$ sh regr.sh
$ sh results.sh
- Make sure you include the required parameters for execution to each file
./regr 1h 2h 3h 4h 5h 6h
./results <test file>.txt
Tested on Pycharm IDE using bash
- Install git shell
- On PyCharm
File->Settings->Tools->Terminal
- Change shell on application settings to
bash.exe
- Execute on terminal
./regr <test file 1> <test file 2> <test file 3>
./results <test>.txt
where <test file 1> => 1h etc
<test> => test1.txt