[Solved] CSCI 3901 Assignment 1

$25

File Name: CSCI_3901_Assignment_1.zip
File Size: 207.24 KB

SKU: [Solved] CSCI 3901 Assignment 1 Category: Tag:
5/5 - (1 vote)

Problem 1

Goal

Get practice in decomposing a problem, creating a design for a program, and implementing and testing a program.

Background

Recommender systems use past behaviours of others to give you suggestions on what has worked for others in the past, based on your own current context. Amazon books, for example, looks at the set of books that you have already purchased and compares your reading list with the reading list of others. It then aggregates the purchases of others who also bought many of the same books as you and recommends to you those books from the aggregate that you havent already purchased. Typically, you dont make a recommendation unless there is enough data to suggest that its a meaningful recommendation.

In this assignment, we will do a simplified version of a recommender system. In our case, you will be recommending courses to take at the university based on what other students have taken.

Problem

Write a class that accepts the list of courses that other students have taken in the past and then allows us to make three queries on that data. I will provide a main program that will then let a user invoke the operations on the data.

The normal use of your class will have the following sequence:

  • Read data from a file
  • Do any of the following, in any order, a number of times o Provide a list of courses and then ask for the best X recommendations of next courses to take (where X is a parameter)
    • Provide a list of courses and have the method print to the screen the number of students with any combined pair of the courses (more details later)
    • Have a method print to a file the number of students with the pairs of courses for any pair of courses (more details later)

We will not add data interactively to the set of courses.

Your class will be called CourseSelector and will include the following methods:

  • Integer read( String filename ) read in the contents of the file to the object. Each line represents the set of courses for a student. Return the number of data rows read. The data should replace any information already in the class. Individual courses in a line will be separated by spaces.
  • ArrayList<String> recommend( String taken, int support, int recommendations ) return a list of recommendations courses for me to take, given that I have already taken the courses in taken. Only report back if the recommendations are based on at least support other students. More information on how to select the courses appears later.
  • boolean showCommon ( String courses ) print to the screen a 2d array where each course in courses has a row and a column (in the order in which they appear in courses). The value at the intersection of a row and a column is the number of students who have taken both courses. More information on the output format later. Return True if you were able to make the computation and False if you encountered any error condition.
  • boolean showCommonAll ( String filename ) print to file filename a 2d array where each known course has a row and a column (in sorted order). The value at the intersection of a row and a column is the number of students who have taken both courses. More information on the output format later. Return True if you were able to make the computation and False if you encountered any error condition.

In all methods, treat course numbers in a case invariant way, so csci3901 and CSCI3901 should be treated as the same course.

Functionality

recommend( String taken, int support, int recommendations)

The method will return the courses that have been taken most frequently with the ones that you provide as the taken parameter.

The basic logic is as follows:

  1. Find all of the students who have taken all of the same courses as provided in taken.
  2. If there are at least support students then
    1. List all of the courses that these students have taken, other than those in taken.
    2. For each course in point 2a, count up how many students have taken that course.
    3. Report back the most frequently taken courses, up to recommendation suggestions.

This logic is provided as a simple guide to understanding the method. You are allowed to re-do the logic however you want.

If you dont have enough students to make a recommendation, then return a null ArrayList.

If you do have recommendations to return, then the returned ArrayList should have at most recommendations entries in it. The courses should be provided in descending order of frequency. Two courses with the same frequency can be in any order.

There is one situation where the ArrayList can have more entries: when you reach recommendations entries and there are other courses with the same frequency that you havent reported. Rather than choose between which of these last courses to return, report all of the ones with that frequency.

For example, suppose that the outcome of computation 2c is the following list of courses:

Course Number of students who have taken it
CSCI1100 12
CSCI2110 10
CSCI2112 8
CSCI2134 8
CSCI3110 5
CSCI3120 4

If recommendations is 2 then you would return CSCI1100 and CSCI2110.

If recommendations is 3 then you would return CSCI1100, CSCI2110, CSCI2112, and CSCI2134 (since the last two both have the same frequency).

If recommendations is 5 then you would return CSCI1100, CSCI2110, CSCI2112, CSCI2134, and CSCI3110.

showCommon( )

Both methods with this method name compute a pairwise popularity matrix. Pairs of courses that are both taken frequently shouldnt be scheduled at the same time, so we want to know the pairs of courses that are both taken often.

The basic logic is as follows:

  1. Create a 2d array with one row and one column for each course that we are given.
  2. Consider the courses of each student in our system.
    1. Find the rows/column number for each of the courses.
    2. For each pair of courses, add 1 to the entry in the 2d array for the pair. Do not pair a course with itself.
  3. Print the resulting matrix.

This logic is provided as a simple guide to understanding the method. You are allowed to re-do the logic however you want.

When you print the matrix, you do not print the column names. For each row of the matrix, print the course name and then the integer from each column. Each of these bits to print will be separated by a tab character.

For example, suppose that we have entries for the following students in our system:

CSCI1110 CSCI2110 CSCI2122

CSCI2110 CSCI2112 CSCI2122 CSCI2134

CSCI1110 CSCI2134 CSCI3171

CSCI2141

If we asked for a matrix for all courses above, we would get the following output

CSCI1110 0 1 0 1 1 0 1

CSCI2110 1 0 1 2 1 0 0

CSCI2112 0 1 0 1 1 0 0

CSCI2122 1 2 1 0 1 0 0

CSCI2134 1 1 1 1 0 0 1

CSCI2141 0 0 0 0 0 0 0

CSCI3171 1 0 0 0 1 0 0

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSCI 3901 Assignment 1
$25