代写Algorithm | 代写Java – CSC B07 Assignment0

代写Algorithm | 代写Java – 这是一个java的基础的project题目

CSC B07 Assignment0

This assignment has two questions. You must complete both the questions correctly.

You are first required to checkout Assignment0 starter code from your SVN repository.

a) Your SVN repository location is of the following form:

https://markus.utsc.utoronto.ca/svn/cscb07f18/YOURUTORID/

where you must replaced YOURUTORID with your actual UTORID

b) You are free to use any IDE that you wish.

c) If you plan on using Eclipse, then there is a short tutorial I have posted on Blackboard under Assignments folder that may be useful in explaining how to checkout the projectusing Eclipse and Subclipse (SVN client that integrates with Eclipse as a Eclipse Plugin). The link to the tutorial is reproduced here as well: http://goo.gl/tL4uYC

Optional: If you like to work on the command line, and like to check out assignment0 on mathlabmachines on UTSC, then this video of mine will help you on how to checkout your assignment0 on mathlab machine using command line and compile/execute using command line on the mathlab machine.

https://www.youtube.com/watch?v=Y7i4QB959PQ

d) The last revision that is present in your SVN repository at time of due date; will be used for grading. We will not mark any previous revisions. You must make sure that the last revision is compilable and that we can execute it correctly.

e) Once you have checked out your project, you will notice that there are three javafiles.

  1. Cfiltering.java
  2. CfilteringDriver.java 3)Rearranging.java

You will use these files to write your code.

Note: Without making any change to the code that you have just checked out. You should be able to compile and run your code as it is and be able to generate the following output: (input1.txt is also on your SVN server and is checked out as well if you follow the steps correctly on the slides posted under Assignment0 module on Quercus. The above screenshot is of running the file CfilteringDriver.java using the input1.txt file) The output is of the starter code without any modification to the starter code.

Question 1)

For this question you will be working on Rearranging.java file that you got from the repository.

Suppose that there is an array and let us call this array, items. This array of items contains n integers. These n integers are in a complete random order in the array. What you are asked to do is to rearrange the items in the array such that all the negative integers come before all the zeros and all the positive integers appear at the end.

Note, this question is not asking you to sort the numbers in the array. It is asking you to rearrange them. Here are some examples, to help you understand the problem.

Example 1:

In this first example, you can see that the array initially contains the integers 7, -3, 0, 0, 8 and -2. Now this is in random order. What you must do to this array, is to rearrange the numbers such that the array has three distinct pieces (also called constraints) represented by <0, ==0 and >0. You can see that in the first region, we place all the numbers that are less than 0, followed by all zeros and then followed by any numbers that are greater than 0.

The numbers within each region can be in any order, as long as they happen to fulfill the constraint.

Here is another example:

Example 2:

I have provided you starter code for this, please make sure to first understand the starter code, and then complete the methods as mentioned in the starter code. And also make sure that your Algorithmruns in linear time. Your loopcan only run once through the array, and you cannot call any sorting functions to sort the entire array.

Do not create any new array, but you must use mutate the original array so that you can rearrange the items in the original array itself.

Question 2) For this question, you will be working on the files Cfiltering.java and CfilteringDriver.java

Part 1)

ONLY PROCEED WITH PART2 of this question, IF YOU HAVE THE OUTPUT AS SEEN IN PART1 (see the figure below). You can produce this output by running your Java program using Eclipse (i.e, make sure to run CfilteringDriver.java ).

Part 2) Sites such as Amazon and Ebay, track-purchasing history of its users and shoppers. When the user logs in, these sites use the information to suggest products that may be of interest to you. Amazon for instance can recommend movies you might like, even if you have purchased books or music from it before.

The data by these sites can be mined in very different ways. Data can be (I like / I dislike), (yes/ no) vote, or as ratings (1 to 5) etc. On the other hand, dating websites try to match up people based on how similar they are. If Jack and Jill have similar interests, Jack may get a recommendation on his profile page Hi Jack, Jill has similar interests as you, do you like to send her a message OR add her as friend?

For this assignment i.e. assignment0 the input file will be of the following format: (Please do not deviate from this format). Note there are line break , new line , and spaces. 4 5

2 3 4 1 1 5 4 2 5 4 4 5 3 1 3 1 1 1 5 5

Where 4 on the first line represents the number of users and 5 on the second line represents the number of movies. The matrix that is followed is a #user x #movie (4×5) matrix. Where rows= #of users=4 and columns= #of movies=5.

The first row of (2 3 4 1 1) means that user1 has rated : (movie1,movie2,movie3,movie4,movie5) as (2,3,4,1,1).

Likewise second row of 5,4,2,5,4 means that user2 has rated: (movie1,movie2,movie3,movie4,movie5) as (5,4,2,5,4).

Your job is to find a similarity score between pair of users that tells how similar they are i.e. Are user1 and user2 more similar based on their rating of movies OR are user3 and user1 more similar? etc.

You can safely assume:

  1. Number of users will be between: 3 # of users 9

  2. Number of movies will be between: 3 # of movies 9.

  3. Rating of movies will be in the range: 1 rating 5

Euclidean Distance Score (How to calculate similarity score?):

The basic idea behind Euclidean distance score is to calculate distance between any two points. For example, the two points are as follows:

  1. Point1 (x,y)= (1,1)
  2. Point2 (x,y)=(3,1)

What is the distance between the above two points?

*****Before you read any further, make sure you understand above how the distance formula works in 2 dimensions x and y*****

Using the above idea, the movies that have been rated in common between users serve as axis or dimensions. The actual users are now data point on the movie graph. One example is provided here:

In the figure, there are 5 blue dots (each blue dot represents a single user) plotted against two movies i.e. Happy Feet and Toy Story. The 5 blue dots or 5 users are as follows:

  1. (x,y) i.e. (ToyStory=2, HappyFeet=2) is user
  2. (x,y) i.e. (ToyStory=3, HappyFeet=2) is user
  3. (x,y) i.e. (ToyStory=4, HappyFeet=3) is user
  4. (x,y) i.e. (ToyStory=4, HappyFeet=5) is user
  5. (x,y) i.e. (ToyStory=5, HappyFeet=5) is user

To calculate the Euclidean Distance between pairs of user in the above figure, we use the Euclidean Distance formula i.e.

This formula actually calculates the distance and we know that for users that are very similar (or very close on the chart) the distance will be less compared to users that are very dissimilar (or very far on the chart).

In order to get higher values (similarity score) for users who are similar we take the inverse of the distance and add 1 to the denominator to avoid division by 0. Hence the final similarity score between these pairs of users (user5 and user1) , (user5 and user4) :

The similarity score is a value between 0 and 1. Value of 0 indicates that the pair of users are very different (dissimilar) and a value of 1 indicates that the pair of users have exactly identical taste. Based on the above-calculated similarity score we can say that (user5 and user4) are more similar compared to (user5 and user1).

In the above figure there are two dimensions (Toy Story and HappyFeet). For multi-dimensions (more than two movies), the Euclidean Distance formula is:

distance (user1, user2) =

a) The userUserMatrix that your program calculates (where columns and rows are User1, User2, User3 and User4) is the following:

Look at the Note section, on how to print the userUserMatrix.

b) Most similar pair of users (both users in the pair MUST be different. If there are more than one pair of different users with the same score, you must list all of them but do not repeat them for example the pair (User1 and User3) is identical to (User3 and User1)): From the userUserMatrix, the most similar pair of users are: User1 and User3.

c) Most dissimilar pair of users (both users MUST be different. If there are more than one pair of different users with the same score, you must list all of them but do not repeat them for example the pair (User3 and User4) is identical to (User4 and User3)): From the userUserMatrix, the most dissimilar pair of users are: User3 and User4.

Note:

–Precision in the userUserMatrix must be rounded off to four decimal places.

–The output from your program MUST contain three entities (SEE THE SAMPLE OUTPUT PROVIDED ON THE LAST PAGE). a) userUserMatrix b) most similar pair(s) of users c) most dissimilar pair(s) of users.

–Print/output your userUserMatrix in a readable form, so it becomes easy for the TA to mark it.

— The template code has lots of comments for you to get started, but your program must have atleast the following functions (you are free to define any signature of the function i.e. take in any number of input of any type and return value of any type. BUT DO NOT CHANGE THE NAME OF THE FUNCTION): a) calculateSimilarityScoreForAllPairsOfUser > this function will calculate the similarity score for all pairs of User b) printUserUserMatrix >this function will print the userUserMatrix to console c) findAnd printMostSimilarPairOfUsers >this function will find and then print the most similar pair of users d) findAnd printMostDissimilarPairOfUsers >this function will find and then print the most dissimilar pair of users

–You MUST create a test folder in your SVN repository, which will reside inside here. (i.e. test folder must be created inside the Assignment0 folder). The name of the folder is case sensitive.

https://markus.utsc.utoronto.ca/svn/cscb07s18/YOURUTORID/Assignment0/

The test folder will contain FOUR test input files that you used to test your code against and that will be different from the two provided.

–At time of marking your assignment, we will not change the input file in any form. All your test input files MUST obey the format of the provided input1.txt and input2.txt

–Have sufficient comments in your code. You do not need to generate Javadoc for this assignment.

–Have sufficient (atleast 6 revisions towards assignment0) revisions with comments in your repository. Do not have all 6 revisions on the day the assignment is due.

–Remove any debugging print messages from your starter code.

You must not exceed the 80-character limit on each line. You can set this easily in Eclipse. (See the slides on this inside the Assignment folder on Blackboard, on how to do this in Eclipse). Also, for this course we will follow the Google Style Java Code. The .xml is available on Blackboard for you to import directly into Eclipse.

Here is a an output, that your program should display when executed with the provided input1.txt: Your output must be identical to what is shown here including all formatting.

Enter the name of input file? input1.txt

userUserMatrix is: [1.0000, 0.1380, 0.2171, 0.1285] [0.1380, 1.0000, 0.1827, 0.1614] [0.2171, 0.1827, 1.0000, 0.1250] [0.1285, 0.1614, 0.1250, 1.0000]

The most similar pairs of users from above userUserMatrix are: User1 and User with similarity score of 0.

The most dissimilar pairs of users from above userUserMatrix are: User3 and User with similarity score of 0.

Here is a an output, that your program should display when executed with the provided input2.txt: Enter the name of input file? input2.txt

userUserMatrix is: [1.0000, 1.0000, 1.0000, 1.0000] [1.0000, 1.0000, 1.0000, 1.0000] [1.0000, 1.0000, 1.0000, 1.0000] [1.0000, 1.0000, 1.0000, 1.0000]

The most similar pairs of users from above userUserMatrix are: User1 and User2, User1 and User3, User1 and User4, User2 and User3, User2 and User4, User3 and User with similarity score of 1.

The most dissimilar pairs of users from above userUserMatrix are: User1 and User2, User1 and User3, User1 and User4, User2 and User3, User2 and User4, User3 and User with similarity score of 1.

Note: There are two line break separate each section in the above output.

发表评论

电子邮件地址不会被公开。 必填项已用*标注