讲解:QBUS6840、visualization、Python、PythonWeb|Java

2019S1 QBUS6840 Assignment 1 Page 1 of 5QBUS6840 Assignment 1 – Homework:Due dates: Friday 12 April 2019Value: 15%RationaleThis assignment has been designed to help students to develop basic predictive analyticsskills on synthetic and possible real applied problems, including data visualization, modelbuilding and analysis in terms of understanding in theory, practices with raw data andprogramming in Python.Tasks1. Consider the (odd order) centred MA-(2+ 1) (i.e. CMA-(2 + 1)) and the two layer(2m+1)x(2n+1)-MA.(a) Show that a 3x5-MA is equivalent to a 7-term weighted moving average and find outall the weights. For general nonnegative integers m and n, argue that a(2m+1)x(2n+1)-MA is equivalent to a X-term weighted moving average. What is X?(b) Write out the formula for the CMA-(2 + 1), and use your general formula to writeout the formula for CMA-11.(c) Prove that when the given time series is periodic with the period 2�+ 1, thesmoothed time series by the CMA-(2 + 1) is a constant series. Find out thevalue of that constant.(d) Again assume that the time series is periodic with the period 2???? + 1. Its firstorder difference time series is defined as�.Prove that the new time series is also periodic with the period M, and identifythe smallest value for M.Apply CMA-(M) to and find out the resulting smoothed time series� You must clearly show each step of reasoning. [25 Marks]2. The data set CBA_1991-2018.csv on Canvas (data was downloaded fromhttps://au.finance.yahoo.com/quote/CBA.AX?p=CBA.AX) contains the monthly stockprices of Commonwealth Bank of Australia (CBA) from August 1991 to December 2018. 2019S1 QBUS6840 Assignment 1 Page 2 of 5(a) Write Python script to load the data and extract High stock prices and make it as atime series with Datetime as index and store it as a new csv file CBA_1991-2018High.csv.Transform the time series data by the first order and the second order differencing andproduce their plots (three plots) in order to become familiar with it. Include the plotsin your submission. You must use Datetime index as the x-axis of your plots.(b) Write your own Python script to implement smoothing using the CMA-24 method andplot the smoothed time series of the original time series series in (a) against it. Andwrite Python code to use pandas package’s rolling_mean function (ver 0.17) orrolling function (ver 0.20+) to re-do the CMA-24 smoothing. Compare results ofyour own implementation and the results of pandas implementation. Have you gotthe same results? Why? Please refer to pandas documentation regarding how to userolling or rolling_mean.(c) Report the scale-dependent measures Root Mean Squared Error (RMSE) and MeanAbsolute Error (MAE) for the methods in (b) [the errors between your smoothedprices and the true prices (be careful of missing smoothed values at the beginningand/or the ending sides!)].(d) The CMA-5 smoothing can be turned into a forecasting method to do one-step aheadforecasting as follows�Use this forecasting method to forecast the last four months in the time series of (a)(i.e., we assume we don’t know them when doing forecasting). Write your ownPython program for the task.(e) It may not be of much accuracy using the CMA-5 forecasting method for a given timeseries. However, for the time series in (a), you may seek for a forecasting methoddefined as�, by using linear regression.For the given time series in (a), formulate a least squared linear regression problemand write your Python program to implement this regression task to work out weights�. You may use all the data except for the last four months in thetime series of (a).With the newly learned weights�, do one-step ahead forecasting forthe last four months.Hint: Given the special condition 4 = 1 on 2019S1 QBUS6840 Assignment 1 , you may design your regression problem such that there are only 4weights (e.g.,to be solved. Think about what the training data shouldbe in this case.(f) Report the scale-dependent measures Root Mean Squared Error (RMSE) and MeanAbsolute Error (MAE) for the methods in (d) and (e) [the errors between predictedprices and the true prices.]. [25 Marks]3. Consider the dataset plastic.csv which consists of the monthly sales (in thousands)of product A for a plastics manufacturer for fives years.(a) Plot the time series of sales of product A. Analyze and identifQBUS6840作业代做、代写visualization留学生作业、Python程序设计作业代做、代写Python课程作y seasonal fluctuationsand/or a trend-cycle?(b) Write your own Python program to implement the classical multiplicativedecomposition to calculate the trend-cycle and seasonal indices. Discuss whetherthe results support the graphical interpretation from part (a).(c) Compute and plot the seasonally adjusted data.(d) Change one observation to be an outliner (e.g., add 500 to one observation), andrecompute the seasonally adjusted data. What is the effect of the outlier?(e) To use the decomposition for forecasting, build a regression model for the trendcyclecomponent, and then use this trend-cycle components and other components tomake three forecasts (one-step ahead, two-step ahead and three-step aheadpredictions).[20 Marks]4. The data set Airline.csv is a famous time series of monthly total international airlinepassengers from Jan 1949 - Dec, 1960. You are required to forecast the next fourmonths’ passenger numbers via using relevant models or methods as specified in thefollowing tasks:(a) Plot the series in your Python program and discuss the main features of the data.(b) Write your own Python script to implement the Holt’s linear trend method on theAirline series. You may follow the Component form athttps://otexts.com/fpp2/holt.html to define a Python function which takes at leastthree arguments, i.e., the time series y, the smoothing parameter for level α and thesmoothing parameter for the trend β, and returns the smoothed time series. Makeyour argument on setting a reasonable value for ????0 and ????0, respectively. In your code,explore the combination of different values of α and β e.g. 0.2, 0.4. 0.6 and 0.8.Calculate and record the one-step ahead SSE (sum of the squared errors) for each pairof values α and β. Choose Four representative smoothed series to plot and use thelegends to indicate corresponding α and β values and SSE. Discuss the effect of α andβ on the forecasts based on the 16 cases, report which values of α and β work best 2019S1 QBUS6840 Assignment 1 Page 4 of 5among 16 cases, and predict what the optimal α and β could be.(c) The Holt’s linear trend method also provides multi-horizon forecast, please refer tohttps://otexts.com/fpp2/holt.html. In your Python program, write code to select theoptimal values of α and β with respect to the two-step ahead (or horizon) forecastSSE. Plot the SSE for the two-step ahead (horizon) forecast against α and β. Use theoptimal two-step ahead α and β to generate forecasts for the next four Months. Plotthe original data series and the smoothing series based on the optimal two-step aheadalpha α and β with all the forecasts, against each other.Hint: This is a 3D plot and you will need to iterate over a range of α and β values[30 Marks]Tips for Tasks1. In your program, you may include the following code to implement SSE.def sse(x, y): return np.sum(np.power(x - y,2))2. In Task 3, you may need build a linear regression model. This can be easily done byusing Python sklearn package (a machine learning package). The following codesection would be helpfulfrom sklearn import linear_modellm = linear_model.LinearRegression(fit_intercept=True)model = lm.fit(X,y) % Fitting linear model to dataforecasts = lm.predict(x) % times series forecastingwhere X and y are input and dependence variables respectively.3. In answering question (c) in Task 4, you may produce about 100 alpha and 100 betavalues, respectively, by usingalphas = np.arange(0.01,1,0.01)betas = np.arange(0.01,1,0.01)Presentation Please submit your project through the electronic system on the Canvas. The assignment material to be handed in will consist of a PDF or WORD document that:i) Details ALL steps.ii) Demonstrates an understanding of the relevant principles of forecasting by showingyour analysis and calculation.2019S1 QBUS6840 Assignment 1 Page 5 of 5iii) Clearly and appropriately presents any relevant tables, graphs and screen dumps fromprograms if any.iv) Provide your program code (if any) as separated py file(s). You will be instructedhow to submit your program code files.Late PenaltyThe assignment is due at Friday 16:00pm 12 April 2019. The late penalty for the assignmentis 5% of the assigned mark per day, starting after 16:00 pm on the due date. The closing date,19 April 2019, 16:00pm is the last date on which an assessment will be accepted for marking.转自:http://www.7daixie.com/2019041013143648.html

你可能感兴趣的:(讲解:QBUS6840、visualization、Python、PythonWeb|Java)