Programming assignment Write, C programming job generation, write C, C + + programming jobs

Source: Internet
Author: User
Tags arithmetic what arithmetic

Programming assignment writing, C programming job generation
Programming Assignment 1:simple Learning
This assignment are designed to provide you some experience writing programs with the C
Programming language and to get a glimpse of how machine learning works. There is significant hype
And excitement around artificial intelligence (AI) and machine learning (ML). For the assignment, you
Would write a C program, implements a simple machine learning algorithm for predicting house
Prices based on historical data.
The price of the house (Y) can depend in various attributes:number of bedrooms (x1), total
Size of the House (x2), Number of baths (x3), and the year of the House were built (x4). If these is the
Only variables this affect price and then the price of the house can is computed by the following equation:
y = w0 + W1 * x1 + W2 * x2 + W3 * x3 + W4 * Y4 (1)
Given A house, we might know the attributes of the house (i.e, X1, x2, x3, x4), however, we
Don ' t know the weights for these attributes:w0, W1, W2, W3 and W4. For instance, have 2 baths
May is more important-some people than others, so the weight of this factor can change based on the
Value people attach to it.
The goal of our machine learning algorithm are to learn the weights for the attributes of the house
From lots of training data. Training data is data, is known (or presumed) to be fully diagnostic and
Representative of what we want to test which is used to ' teach ' the machine algorithm. The algorithm would
Then take what it had ' learned ' from the training data and later apply it to testing data, data where some
of the factors and variables is not known, and would estimate the most likely values for those factors
and variables.
Presume we have n examples in a training data set that provide the values of all attributes for N
Houses and the price. Let ' s say there is K attributes. We can represent the attributes from all the
Examples in the training data as a N x (K + 1) matrix as follows, which we call x:
[
1 x0,0 x0,1 x0,2 x0,3
1 x1,0 x1,1 x1,3 x1,3
1 x2,0 x2,1 x2,2 x2,3
1 x3,0 x3,1 x3,2 x3,3
...
1 xn,0 xn,1 xn,2 xn,3
]
where n is n? 1. We can represent the prices of the house from the examples in the training data
As a N x1 matrix, which we call Y:
[Y0y1. Yn
]
Similarly, we can represent the weights for each attribute as a (K + 1) x1 Matrix, which we call W:
[W0W1. wk
The goal of our machine learning algorithm are to learn this weight matrix from the training data.
Now in the matrix notation, entire learning process can is represented by the following equation,
Where X, Y, and W are matrices as described above:
X * W = Y (2)
In particular, each weight times the variable-parameter of a house equals the price, for
All houses and their corresponding prices.
Using the training data, we can learn the weights using the below equation:
W = (x T * x)? 1 * XT
* Y (3)
X
T
is the transpose of the Matrix X. X-1 is the inverse of the Matrix x, so (x T * x)? 1 is the
Inverse of (x T * x).
Your main task in this part to implement a program to read the training data and
Learn the weights for each of the attributes, which you'll use to predict housing prices in the test
Data set.
In order to does this, you'll have to implement functions to multiply matrices, transpose
matrices, and compute the inverses of matrices.
While you don ' t need to understand the theory behindthis type of machine learning in order to
Write the code, you can learn more on it at particular, the algorithm your is computing is known as ' linear Regressi On ',
In particular linear regression with the least square error as the error measure (often abbreviated in
Speech as "Lin Least Squares") and is used in many fields. The Matrix (x T * x)? 1 * XT is known as the
' Pseudo-inverse ' of X and is useful in many computational methods.
Computing the inverse using Gauss-jordan elimination
To compute the weights above, your program have to compute the inverse of matrix. There is
Numerous methods to compute the inverse of a matrix. For this project should compute the inverse
Using Guass-jordan elimination, described below. IF you compute inverse using any other method, you
Would risk losing all points for the this part.
An inverse of a square matrix A are another square matrix B, such that a*b = B*a = I, where I am
The identity matrix. This was similar to the idea of arithmetic inverses; 2/1 * 1/2 = 1. The identity matrix I
is a matrix such this, for any square matrix, a:a * I = A. An identity matrix was a matrix of 0s with 1s on
The diagonal.
Gauss-jordan Elimination for computing inverses
Below, we give a sketch of Gauss-jordan elimination method. Given a matrix A whose inverse needs to
Be computed, your first create a new ' augmented ' matrix, called Aaug, by concatenating the identity
Matrix to the end of A, as shown below:
Matrix A:
[
1 2 4
1 6 7
1 3 2
]
The augmented matrix (Aaug) of A is:
[
1 2 4 1 0 0
1 6 7 0 1 0
1 3 2 0 0 1
]
That's the easy part. The next part was to perform arithmetic operations on the rows of the augmented
Matrix to change the part, the is A (the first 3 columns, in this case) in to the identity matrix. In other
Words, the first 3 columns look like the last 3 columns.
The row operations you is allowed to the use of compute the inverse for this assignment is:
? You can divide the entire row by a constant
? You can subtract a row by another row
? You can subtract a row by another row multiplied by a constant
You aren't allowed to swap the rows. Be careful! In the traditional Gauss-jordan elimination method,
You are. Do not swap rows in this assignment.
Below is an example of computing the inverse of A using Aaug and the row operations detailed above.
Since Our goal are to transform A part of the augmented matrix into an identity matrix, let's start
At the first element, Aaug[0][0] is 1, good! That's what it should was for the identity matrix. Next row.
Aaug [1][0] is not 0, but 1. This needs to the change. There is a 1 in the first column of the first row (we
Just made sure of this), so we'll subtract the first row from the second row because we want to make
Aaug [1][0] = = 0. Hence, we perform the operation R1 = R1? R0, where R1 and R0 represents the
Second and first row of the augmented matrix. Augmented matrix Aaug after R1 = R1? R0
[
1 2 4 1 0 0
0 4 3-1) 1 0
1 3 2 0 0 1
]
Now we want to make Aaug [1][1] = = 1. Hence, we perform the operation R1 = R1/4. The augmented
Matrix Aaug After R1 = R1/4 is:
[
1 2 4 1 0 0
0 1 3/4 -1/4 1/4 0
1 3 2 0 0 1
]
Next, we want to make Aaug [2][0] = 0. Hence, we perform the operation R2 = R2? R0. The
Augmented matrix Aaug after R2 = R2? R0 is:
[
1 2 4 1 0 0
0 1 3/4 -1/4 1/4 0
1 1-2-1 0 1
]
Next, we want to make Aaug [2][1] = = 0. Hence, we perform the operation R2 = R2? R1. The
Augmented matrix Aaug after R2 = R2? R1 is:
[
1 2 4 1 0 0
0 1 3/4 -1/4 1/4 0
0 0-11/2 -3/4 -1/4 1
]
Now, we want to make Aaug [2, 2] = = 1, Hence, we perform the operation R3 = R3 *-4. The
Augmented matrix Aaug After R3 = R3 * – 4 is:
[
1 2 4 1 0 0
0 1 3/4 -1/4 1/4 0
0 0 1 3/11 1/11-4/11
]
Next, we want to make Aaug [1, 2] = = 0, Hence, we perform the operation R1 = R1? 3/4 * R2.
Aaug then becomes:
[
1 2 4 1 0 0
0 1 0-5/11 2/11 3/11
0 0 1 3/11 1/11-4/11
]
Next, we want to make Aaug [0, 2] = = 0, Hence, we perform the operation R0 = R0? 4 R2. Aaug?
Then becomes:
[
1 2 0 1/11-4/11 16/11
0 1 0-5/11 2/11 3/11
0 0 1 3/11 1/11-4/11
]
Next, we want to make Aaug [0, 1] = 0, Hence, we perform the operation R0 = R0? 2 R1. Aaug then?
becomes:
[
1 0 0 9/11-8/11 10/11
0 1 0-5/11 2/11 3/11
0 0 1 3/11 1/11-4/11
]
At this time, the A part of the augmented matrix was an identity matrix and the inverse of the original
Matrix A is now the augmented part, the "the" we originally tacked on the the "the" as an identity
Matrix
[
9/11-8/11 10/11
-5/11 2/11 3/11
3/11 1/11-4/11
]
To understand what this is, think of what arithmetic inverses work. For regular arithmetic ' 1 ' is
The identity value, since n * 1 = n, for any number. If you had any number X and want to compute its
Inverse, you want a number, y such that:x * y = 1. So, any modification made by X are reversed by
Its inverse, or to say it another, multiplying by X and then Y are the same as multiplying by identity.
The operations above start with matrix A and then record all operations you need to does to turn it into
The identity matrix. Those recorded operations is then the inverse of A. If you can multiply by A and
Then by A Inverse and you get the same result as has multipled by the identity matrix.
Great. Why does care? Well, if you had a matrix of weights that is applied to a vector of
Parameters, you'll get a vector of prices. The training data would be is, except for the weights. For a
Given set of houses with certain parameters, they sold for a certain amount. IF You compute the inverse
Of this multiplication, you can discover the weights that were applied to get from parameters to the
Prices-and then the can apply those weights to new data.
Input/output specification
Usage interface
Your program learn would be executed as follows:
./learn <train-data-file-name> <test-data-file-name>
Where <train-data-file-name> is the name of the training data file with the attributes and price of
A house. You can assume the training data file would exist and that it's well structured. The
<test-data-file-name> is the name of the "the" and "the" attributes of the house. You have to
Predict the price of the house is entry in the test data file.
Input specification
The input to the program would be a training data file and a test data file.
Training Data files
The first line in the training file would be a integer that provides the number of attributes (K) in
The training set. The second line in the training data file would be is an integer (N) providing the number of
Training examples in the training data set. The next n lines represent the n training examples. each
Line for the example is a list of comma-separated double precision floating point values. The first
K double precision values represent the values for the attributes of the house. The last double precision
Value in the represents.
An example training data file (train1.txt) is shown below:
4
7
3.000000,1.000000,1180.000000,1955.000000,221900.000000
3.000000,2.250000,2570.000000,1951.000000,538000.000000
2.000000,1.000000,770.000000,1933.000000,180000.000000
4.000000,3.000000,1960.000000,1965.000000,604000.000000
3.000000,2.000000,1680.000000,1987.000000,510000.000000
4.000000,4.500000,5420.000000,2001.000000,1230000.000000
3.000000,2.250000,1715.000000,1995.000000,257500.000000
In the example above, there is 4 attributes and 7 training data examples. Each example have values
For the attributes and last value are the price of the house. To illustrate, consider the training example
Below
3.000000,1.000000,1180.000000,1955.000000,221900.000000
The first attribute has value 3.000000, the second attribute have value 1.000000, third attribute has value
1180.000000, and the fourth attribute has value 1955.000000. The price of the house for these set of
Attributes is provided as the last value in the line:221900.000000
Testing data files
The first line in the testing file would be a integer (M) that provides the number of the test data
Points in the file. Each line would have K attributes. The value of K is defined in the training data file.
Your goal is predict, the price of house for each line in the test data file. The next M lines represent the
M test points for which you has to predict the price of the house. Each line would be a list of commaseparated
Double precision floating point values. There would be a K double precision values that represent
The values for the attributes of the house. An example test data file (test1.txt) is shown below:
2
3.000000,2.500000,3560.000000,1965.000000
2.000000,1.000000,1160.000000,1942.000000
It indicates that you had to predict the price of the house using your training data for 2 houses. The
Attributes of listed in the subsequent lines.
Output specification
Your program should print, the price of the house for each line in the test data file. Your Program
should not produce any additional output. If the fractional value, then your
Program should round it to the nearest integer, which you can accomplish with the following printf
Statement
printf ("%0.0lf\n", value);
Where value is a double holding the "The price" of the house.
Your program should predict the price of the entry in the test data file by substituting the attributes
and the weights (learned from the training data set) in equation (1).
A sample output of the execution when your execute your program as shown below:
./learn Train1.txt Test1.txt
... should be:
737861
203060
Hints and Suggestions
? You is allowed to the use functions from the standard libraries and you cannot use Third-party libraries
Downloaded from the Internet (or from anywhere else). If you is unsure whether you can use
Something, ask us.
? We'll compile and test your program on the ILab machines so do should make sure that your
program compiles and runs correctly on these machines. You must compile all C code using the
gcc compiler with the-wall-werror-fsanitize=address flags.
? You should test your program with the Autograder provided with the assignment.
Submission
Your submission should be a tar file named Pa1.tar. To create this file, put everything.
Submitting into a directory named PA1. Then, CD. Into the directory containing PA1 (which is, PA1 ' s
Parent directory) and run the following command:
Tar cvf Pa1.tar PA1
To check so you have correctly created the tar file, and you should copy it into an empty
Directory and run the following command:
Tar xvf Pa1.tar
This should create a directory named PA1 and all your project files in it.
The PA1 directory in your tar file must has:
? Makefile:there should is at least, in your Makefile:
Learn:build your learn executable.
Clean:prepare for rebuilding from scratch.
? Source Code:all source code files necessary for building your programs. Your code should contain
At least Files:learn.h and LEARN.C.
Grading guidelines
We'll automatically build a binary using the Makefile and source code that you submit, and then test
The binary for correct functionality and efficiency against a set of inputs.
? We should is able build your program by just running make.
? Your program should follow the format specified above for both both the parts.
? Your program should strictly follow the input and output specifications mentioned.
Note:this is perhaps the most important guideline:failing to follow it might result in you losing
All or most of the your points for this assignment. Make sure your program ' s output
Format is exactly as specified. Any deviation would cause the automated grader to mark
Your output as "incorrect". Requests for re-evaluation of programs rejected due to improper formatting
Won't is entertained.
? We'll check all solutions pair-wise from all sections of this course (including those of parallel
Lectures) to detect cheating using computational LINGUSITC software and related tools. IF-Submissions
is found to be similar, they'll instantly be awarded zero points and reported to office of student
Conduct. See Rutgers CS ' s academic integrity policy at:
We provide the Autograder to test your assignment. Autograder is provided as Autograder.tar.
Executing the following command would create the Autograder folder:
Tar xvf Autograder.tar
There is modes available for testing your assignment with the Autograder.
First mode
Testing when is writing code with a PA1 folder:
1. Lets say you has a PA1 folder with the directory structure as described in the assignment.
2. Copy the folder to the directory of the Autograder
3. Run the Autograder with the following command
Python PA1 autograder.py
It'll run the test cases and print your scores.
Second mode
This mode was to test your final submission (i.e, Pa1.tar)
1. Copy Pa1.tar to the Autograder directory
2. Run the Autograder with Pa1.tar as the argument. The command line is:
Python PA1 autograder.py Pa1.tar
The autograder would decompress your tar file and run the check code against it.
Http://www.daixie0.com/contents/13/1242.html

The core staff of the team mainly include Silicon Valley engineers, bat front-line engineers, domestic TOP5 master, PhD students, proficient in German English! Our main business scope is to do programming big homework, curriculum design and so on.

Our Direction field: Window Programming numerical algorithm AI Artificial Intelligence financial statistical Metrology analysis Big Data network programming Web programming Communication Programming game Programming Multimedia Linux plug-in programming API image processing embedded/Microcontroller database programming console process and thread Network security assembly language Hardware programming software Design Engineering Standard Rules. The generation of programming languages or tools including, but not limited to, the following ranges:

C/c++/c# Write

Java Write generation

It generation

Python writes

Tutoring Programming Jobs

The MATLAB Generation writes

Haskell writes

Processing Write

Linux Environment Setup

Rust Generation Write

Data Structure assginment Data structure generation

MIPS Generation Writing

Machine Learning Job Writing

Oracle/sql/postgresql/pig database Generation/Generation/Coaching

Web development, Web development, Web site jobs

Asp. NET Web site development

Finance insurace Statistics Statistics, regression, iteration

Prolog write

Computer Computational Method Generation

Because of professional, so trustworthy. If necessary, please add qq:99515681 or e-mail:[email protected]

: Codinghelp

Programming assignment Write, C programming job generation, write C, C + + programming jobs

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.