June 24, 2016
Machine Learning | Sentiment Analysis on Tweets about the Scotland Independent Vote in 2014

Topic Description
As we know the result of Scotland independent vote is that Scotland still a part of the UK in 2014. In this practicum, we will implement an appropriate machine learning model which could predict the opinion (supportive or not opposed or neutral) of the related tweets to Scotland independence.

Machine Learning
Machine learning is the science of getting computers to act without being explicitly programmed. In the past decade, machine learning has given us self-driving cars, practical speech recognition, effective web search, and a vastly improved understanding of the human genome. Machine learning is so pervasive today that you probably use it dozens of times a day without knowing it. Many researchers also think it is the best way to make progress towards human-level AI.

Sentiment Analysis
Sentiment analysis, also called opinion mining or sentiment mining, is a process which analysing and reasoning the subjective sentimental text, is the detection of attitudes.

Brief Study Steps
1. Download the tweets (as the dataset) through the twitter’s API, i.e. each tweet should at least has the hashtag like #Scotland #independent #vote etc. before 18 September 2014 (the voting date), or other conditions could show that tweet is related to the Scotland independent vote around that time. Then clean the dataset, divide it into training set (more than 500 tweets), tuning set (more than 500 tweets) and testing set (more than 500 tweets).

2. Annotate each tweet in the training set as “positive”, “negative” or “neutral”.

3. Training a machine translation model to predict the attitude of the tweets whether it was supportive or opposed or neutral to Scotland independence. Different machine learning models/algorithms/functions will be tested with the combination of different feature selection and parameter setting.

June 21, 2016
finance | ENGR105 | Homework 3

Homework 3
Due by 9am 6/21/16. Submit 5 files.
Problem 1. In finance, many times you have estimates of how much expenses will cost and how much revenue will be brought in. However, it is very rare that you have those values ahead of time while making decisions. Each financial decision has a large amount of variability. To deal with this variability, financial advisers use tools to process the expected profit as well as the variance, if problems appear. A Monte Carlo simulation is one of those tools. Here you will create a Monte Carlo simulation as a basic financial model for decision making.
The most basic model of a company’s money flow is:
Net Profit = Sales Volume* (Selling Price – Unit cost) – Fixed costs
Imagine that you are working for Mathworks and trying to determine the profitability of producing the student version of Matlab. To produce the discs, you would have to pay for a new factory (FixedCosts=150000±1000 per month) as well as the cost of the disc/packaging/server usage/etc (UnitCost=10±4). If the selling price is set at $100 (SellingPrice=100) and you expect to sell 2000±200 copies per month (SalesVolume=2000±200), what is the likelihood that you would make a profit?
NOTE: For this problem, we will assume that all variability in our random variables is Gaussian in nature. Consequently, something like “FixedCosts=150000±1000 per month” means that the fixed costs for a given month will be a number randomly selected from a normal distribution with mean 150000 and standard deviation 1000. Also, we will assume that the cost for each unit is constant for a given month (ie, if you sell 1978 units in a given month, each of those units will have the same cost – there will not be 1978 different costs). Finally, we will allow negative values for fixed costs, unit cost, and sales volume, though they are very unlikely (so, no extra adjustments need to be made to the random numbers).
The steps below should guide you to your answer and explore the important aspects of Monte Carlo simulation:
a. Create a loop that on each iteration calculates and saves a value for a monthly NetProfit according to the formula given above. In order to do this, a value for each variable on the righthand side of the formula needs to be set in each iteration of the loop (using random numbers to select a value from your distributions when necessary). This loop should be implemented in a function called matlab_monte_carlo. An input to this function should be the number of monthly net profits to estimate (you may choose to include other input arguments); the output from this function should be a vector of estimates of net profits (one element per iteration of the loop).
• Remember that you can use randn to generate random numbers selected from the standard normal distribution. You can make use of these values to obtain random numbers selected from normal distributions with other means/standard deviations. You
Homework 3
Due by 9am 6/21/16. Submit 5 files.
are also welcome to search for/make use of other Matlab commands (especially ones in
various toolboxes) that may help you in generating the random numbers that you need. b. Plot the histogram of NetProfit values, noting somewhere on the plot how many monthly net
profits this represents (your input to the function). Make sure to that your histogram is presented (number of bins, bin locations, labeling, etc) in a way that provides appropriate, effective, useful communication. Discuss (in a comment) how changing the number of times you are calculating net profits changes the plot.
NOTE: Your code should run pretty quickly for these.
NOTE: Before you start using matlab_monte_carlo and the random numbers that it generates, please initialize the state of the random number generator appropriately (ie, so that it will be in a “random” state).
Problem 2. For this problem you will be using the image file beach.jpg. This should be written as a function with an input argument of a .jpg filename and no output arguments. Name both the function and file beach_plot. Include comments and help lines. Do not include any images in your submission, your script should create them all.
a. Assume the user will have the beach.jpg file in the current directory and will run the function by typing beach_plot(‘beach.jpg’); in the command line.
b. Ask the user to select a point anywhere in the image. Use this point to create 4 quadrants to your image (imagine this in your head, you’re not doing anything with it quite yet).
c. Create a new image where
i. In the upper left quadrant, you plot the original portion of the image without any red
(the red portion is zero)
ii. In the upper right quadrant, you plot the original portion of the image without any
iii. In the lower left quadrant, you plot the original portion of the image without any blue
iv. In the lower right quadrant, you plot the original portion of the image
d. An example is shown below. Hint: if you are getting the message “Integer operands are required for colon operator when used as index” look into the floor command and ask yourself, does my user have to pick a point exactly between two pixels? Note: “Warning: Image is too big to fit on screen” is an ok error to get since it depends on the individual screen resolution.
Homework 3
Due by 9am 6/21/16. Submit 5 files.
Problem 3. For this problem you will be creating a .wav file of twinkle twinkle little star. I have written a function for your use called note_freq which takes an input character and converts it to the corresponding musical frequency. For example, the C on a piano above “middle C” corresponds to a frequency of 523.28 Hz.
You should create a function named twinkle that plays the tune “ccggaag” pause “ffeeddc” by calling the function note_freq. I do not want to see individual lines of code calling each and every note – condense using your programming skills. The function should also write a .wav file with a name specified by the user. The function input arguments should be 1) the sampling rate in Hz at which the song should be played and saved (20000Hz is a good number to play with) and 2) the desired filename which the song will save to. It will be assumed that note_freq is in the current folder. Include help lines and comments. Play the song once at the desired rate in addition to saving it to file.
Note: in case you’re feeling creative, you can add more notes and play pretty much anything http://www.phy.mtu.edu/~suits/notefreqs.html

Homework 3
Due by 9am 6/21/16. Submit 5 files.
Problem 4.
To get started: Create a structural array containing all of the information needed to plot a data set. At a minimum, the structural array should have the following fields
x_data y_data type plot_title x_label y_label x_range y_range
x data (one or more data sets in separate cells) y data (one or more data sets in separate cells) linear, semilogx, and so on
plot title
x axis label
y axis label
x axis range to plot y axis range to plot
You may add additional fields that would enhance your control of the final plot.
The real assignment: After this structural array is created, create a function that accepts a structural array of this format and produces one plot for each structure in the array. The function should apply intelligent defaults if some data fields are missing. For example, if the plot_title field is an empty matrix, then the function should not place a title on the graph or cause an error. Think carefully about the proper defaults before starting to write your function!
To test your function, create a structure array containing the data for three plots of three different types and pass that structure array to your function. The function should correctly plot all three data sets in three different figure windows. The data, labels, titles, ranges, types etc should be different for all three plots.
What to turn in: A script named input_struc.m containing your test structure with the information for the three plots (described above). A function named plot_struc.m that is able to take your structural array and plot all three graphs in different figure windows.
How I will test this: First, I’ll create a variable using your script file and run it through your function. Then, I will use a structure of my own (but following your formatting) that may be missing information from certain fields and try and run it through your function.

June 9, 2016







June 6, 2016
Java | Game|Java Game Agent

For this project you will be implementing an agent to play a simple text-based adventure game. The agent is required to move around a rectangular environment, collecting tools and avoiding (or removing) obstacles along the way. The obstacles and tools within the environment are represented as follows:
Obstacles Tools
T tree a axe
– door k key
~ water o stepping stone
* wall g gold

The agent will be represented by one of the characters ^, v, < or >, depending on which direction it is pointing. The agent is capable of the following instructions:

L turn left
R turn right
F (try to) move forward
C (try to) chop down a tree, using an axe
U (try to) unlock a door, using a key

When it executes an L or R instruction, the agent remains in the same location and only its direction changes. When it executes an F instruction, the agent attempts to move a single step in whichever direction it is pointing. The F instruction will fail (have no effect) if there is a wall, tree or door directly in front of the agent.