Author: admin

  • Using a Timer • Using a null layout • Using paintComponent • Using the keyboard listener…

    jr penn state canvas – Google Sec:: X Q1 L09: Lab Assignment – Java: The X
    ure.com/courses/1971921/assignments/10499343#submit
    Bookmarks
    What You Will Learn
    • Using a Timer • Using a null layout • Using paintComponent • Using the keyboard listener
    Contents
    • Lab 09 Demo: Video with Transcript (0:49) E.,:
    • Lab 09 Demo: MP4 Download (2.6 MB) r2 1. The objective of the lab is to create a game in which the player has to click on a moving button to score in 60 ticks of the timer. 2. The game starts when the user press the space bar. This user action will be detected by the required use of a Keyboard Listener. 3. The button has to move constantly (using the timer) after the space bar is clicked. 4. The application has to keep score. 5. The actual score has to be shown using paintComponent repaint function. 6. For every tick of the timer, the timer speed will increase by 10 milliseconds (the timer delay will decrease) 1. you will use a JProgressBar on the right to display the time decrease. It will count from 60 to 0. 7. Every time the user clicks on the button and scores the button size has to decrease. 8. All listeners have to be implemented as reviewed in the lessons 1. public class GamePanel extends JPanel implements 2. inner listeners will not he accepted
    0 Vel I I
    •
    10•¦¦•¦••••¦••••¦•¦..
    111¦111•11M,
    ¦•¦¦•¦•, ••¦ F2 F3 F4 F5 F6 F7 F8 F9 FAO FAA F12 4, 1 44 131 P 4F:
    Attachments:
    3164836_1_2870002-3-81b16df5-128b-4db3-aa8c-49fac0d42174.jpeg
    3164836_2_2870002-2-3663192f-02fa-4b89-9473-32fc54382bfb.jpeg

  • Literature: see links below, and on the handout from the pract…

    Search the library database to find three studies that answer your research question. All three studies must be of different study designs. For instance, you could include observational studies, cross sectional, case control, and cohort as well as RCTs. These studies do not have to prove their hypothesis or agree with each other. Please note that marks will be deducted if all identified papers are of similar study.
    2. Critically appraise all three articles you found using the GASP checklist. Make sure you use the relevant CAW checklist corresponding with your study design. Please note that you will need to make 3 different tables for the critical appraisal of the three different study design papers.
    1 Submit the Part A of the three tables for feedback before writing up Part B (essay).
    Part B
    Base on the feedback in Part A, you should write an essay on the three articles using the following headings:
    Introduction: introduces the topic, outlines background information to your research question and finishes with the research question. This sets the context for the rest of the assignment. You may refer to any published articles as they would have the same style of scientific writing. Citation for all sources used (in-text and in the reference list).
    Methodology: explain how you found the three articles that you critically reviewed, including the databases you used and the search strategy/keywords used. You may use a systematic review as an example to write this part. Also mention which critical appraisal tools you used
    Results: answer directly to all the relevant CAW checklist question, You MUST present a table. Additionally, create a column to include ‘justification’ to your decision of each question, i.e. Yes, No, Unclear.
    Disassion: dixuss all three papers of different study designs in regards to bias, chance and confounding factors. All answers of ‘YES, NO and UNCLEAR’ in your result MUST he accompanied by an explanation on how you can avoid pitfalls (bias, confounding factor), improve on the current methodology, or to further support by comparing and contrasting other approaches to an issue. Provide suggestions or solutions for future research of your research question/topic.
    Conclusion: provide one concluding paragraph based on what you have discussed.
    References: include all the sources you have used within your text and organize them in alphabetical order according to APA 6. edition style.
    PUBH6005_Asseument Brief 3 Page 2 of 8
    I I Al IDFATF
    OPEN IN…
    • • •
    Attachments:
    3164848_1_2871431-1-32b92d53-b671-47bd-a251-7e2320da5919.png

  • MAE301 Homework 4 March 13, 2019 Please submit your homework as a single pdf through Canvas. You…

    MAE301 Homework 4 March 13, 2019 Please submit your homework as a single pdf through Canvas. You can take pictures of your hand-written work and attach them to the pdf. 1 Problem Description You are given the data “dat train.txt” which includes a set of cars with their attributes. Your goal is to build a linear model that considers the price of cars (the first column in the data) as the response of the other car attributes. The homework will be graded based on two parts: (50pt) The following report on model estimation and selection, and (20pt) the prediction performance of your model using a set of test data. Details will be explained as follows. 2 Preparation You will need numpy and matplotlib, as usual, but the standard machine learning packages from Scikit-Learn. # use this if you are using jupyter notebook, otherwise comment it out %matplotlib inline # loading all packages… # import numpy as np from sklearn import decomposition from sklearn.model_selection import train_test_split from sklearn.pipeline import Pipeline from sklearn.preprocessing import PolynomialFeatures from sklearn.model_selection import cross_val_score import matplotlib.pyplot as plt Next, you will need to import the data, as an array. Please make sure the .txt file is in the same directory/folder as your code. data = np.genfromtxt(’dat_train.txt’) var=[’Price’, ’Engine size’, ’Cylinders’, ’HP’, ’City MPG’, ’Highway MPG’, ’Weight’, ’Wheel base’, ’Length’, ’Width’] 1 In class we talked about Data Preprocessing: The data columns should have zero mean and unit variance. In other words, the data should be centered at the origin and the scales of attributes should not be too different. One way to preprocess is to use an appropriate scaling function in the sklearn.preprocessing sub-module. You can find the documentation here. In the following code, complete the import by erasing the “???” and replacing them with the proper function. from sklearn.preprocessing import ??? #import the standard scaler scaler_func=???() # assign standard scaler to a variable “scaler_func” scaler_func.fit(data) # train the scaler for use later data_scaled = scaler_func.transform(data) # preprocess the data 3 Ordinary Least Square (20pt) Like before, find the appropriate function for linear regression (this time in the sklearn.linear model submodule) 3.1 Complete the below code. (5pt) from sklearn.linear_model import ??? # response are car prices, i.e., the first column of the data matrix # y_train = data_scaled[:,0] # covariates are the other columns. Dealer cost is not included # since it correlates too much with the price # X_train = data_scaled[:,1:] ncv = 10 # number of cross valiation folds *KEEP THIS CONSTANT* lin_reg = ???() #new “modelling” object lin_reg.??? # do regression on the above yhat = lin_reg.??? #predict prices based on the model # Evaluate the models using crossvalidation scores = cross_val_score(lin_reg, X_train, y_train, scoring=”neg_mean_squared_error”, cv=ncv) #### Leave the following plotting code as-is #### from matplotlib import gridspec plt.figure(figsize=(12, 7)) gs = gridspec.GridSpec(1, 2, width_ratios=[3, 1]) ax = plt.subplot(gs[0]) plt.scatter(y_train, yhat, label=”Linear 1deg OLS”, clip_on=False) plt.title(“CV avg score: {:.3}”.format(abs(scores.mean()))) plt.xlabel(“True car price”) 2 plt.ylabel(“Predicted Car Price”) plt.xlim((min(y_train), max(y_train))) plt.ylim((min(yhat), max(yhat))) plt.plot(range(100000), label=”perfect prediction”) plt.legend() ax = plt.subplot(gs[1]) ypos = np.arange(len(var[1:])) plt.barh(ypos, lin_reg.coef_, align=’center’) plt.yticks(ypos, var[1:]) ax.yaxis.tick_right() plt.title(“Coefficient Loadings”) plt.xlim([-1,1]) fig.tight_layout(pad=1.9) ###################################### 3.2 Discussion (15pt) Is the model reasonable? For what range of prices is the prediction the best? What does the CV score mean (should it be large or small)? 4 Model Selection (30pt) In this section, we will discuss model selection using three criteria: crossvalidation (cv), AIC and BIC. We will investigate how model complexity affects the training error and these model selection criteria. To do so, we will make use of a neat API in sklearn called pipeline. This let us queue up a bunch of modeling tasks and perform all of them, as long as the same data is being used. Specifically, we’ll tell the pipeline to automatically generate the columns for models with different order of polynomials, and then fit them using linear OLS. Once again, fill out the “???” by reading the docs on pipeline. Use the linear OLS from the last problem, and find sklearn’s function for automatically generating the polynomial columns, in the sklearn.preprocessing submodule. 4.1 Complete the code (10pt) from sklearn.pipeline import Pipeline from sklearn.preprocessing import ??? # find the module from # sklearn.preprocessing that generates polynomial terms # a set of linear models with polynomial terms degrees = [???] # make a list of all degrees of polynomial models to try scores = np.zeros((len(degrees),ncv)) # cv error, for each model type error = np.zeros(len(degrees)) fig=plt.figure(figsize=(16, 5)) 3 for i in range(len(degrees)): polynomial = ???(degree=degrees[i], include_bias=True, interaction_only=True) lin_reg = ???(fit_intercept=False) # our data has been scaled, no need for intercept pipeline = Pipeline([(“Polynomial Features”, polynomial), (“Linear OLS”, lin_reg)]) pipeline.??? # do regression on the above yhat = pipeline.??? #predict prices based on the model # Evaluate the models using crossvalidation scores[i,] = cross_val_score(pipeline, X_train, y_train, scoring=”neg_mean_squared_error”, cv=ncv) # add the new CV scores # Calculate the training error error[i] = ((yhat – y_train)**2).sum() #### Leave the plotting code as-is #### n = yhat.shape[0] ax = plt.subplot(1, len(degrees), i + 1, sharey=ax) plt.setp(ax, xticks=(), yticks=()) plt.scatter(y_train, yhat, label=”Linear “+str(degrees[i])+”deg OLS”, clip_on=False) plt.title(“CV avg score: {:.3}nAIC = {:.2e}nBIC = {:.2e}”.format(abs(scores[i,].mean()), 2*polynomial.n_output_features_+ n*np.log(error[i]/n) , np.log(y_train.shape[0])*polynomial.n_output_features_+ n*np.log(error[i]/n) )) plt.xlim((min(y_train), max(y_train))) plt.ylim((min(yhat), max(yhat))) plt.plot(range(100000), label=”perfect prediction”) plt.xlabel(“True Car Price”) plt.ylabel(“Predicted Car Price”) plt.legend() % fig.suptitle(“Prediction and “+str(ncv)+” Cross-validation for polynomial fits (deg 1-4)”) 4.2 Discussion (20 pt) Based on the above, which model seems to be the “best”? What is happening as the model complexity increases? 5 Design Your Own Model (20pt) Now that you learned the basics of how model is built and selected, it is time to investigate by yourself an appropriate model for this data. The model does not 4 have to contain only polynomial terms. Report the crossvalidation, AIC and BIC scores for your model. If you’re struggling to find a good model, try plotting histograms of the individual variables. If there are ranges with unusually large counts, you may want to find a function that reshapes that variable accordingly. Lastly, please apply your model on the test data ”dat test.txt” and report the mean square error using the following code. #import the test data test = np.genfromtxt(“dat_test.txt”) print test.shape test_scaled = scaler_func.transform(test) Xt = test_scaled[:,1:] #print test[:,1:].mean(axis=0) yt_scale = test_scaled[:,0] yt = test[:,0] fig, ax = plt.subplots(ncols=2, figsize=(12, 6)) # First the Linear OLS yhat_scale=lin_reg.predict(Xt) yhat = yhat_scale*y.std()+y.mean() ax[0].scatter(yt, yhat) ax[0].plot(range(100000)) residual = np.sqrt(np.sum((yt-yhat)**2)) ax[0].set_title(“OLS Residual: {:.3}”.format(residual)) 6 Read More: LASSO (Least Absolute Shrinkage and Selection Operator) Here we introduce a commonly used yet more sophisticated linear regression method called LASSO. The key idea is that we prefer simple linear models, i.e., model with only a few non-zero weights, so that the model is easy to interpret, and more generalizable (see Occam’s Razor). In order to achieve this, LASSO penalizes the magnitudes of weights. from sklearn.linear_model import LassoCV, Lasso model=LassoCV(cv=ncv, fit_intercept=False) #alpha based on CV for ncv from above model.fit(X_train, y_train) yhat = model.predict(X_train) print model.alpha_ scores = cross_val_score(model, X_train, y_train, scoring=”neg_mean_squared_error”, cv=ncv) print “CV avg MSE “,-1*scores.mean() print model.coef_ 5 from matplotlib import gridspec plt.figure(figsize=(12, 7)) gs = gridspec.GridSpec(1, 2, width_ratios=[3, 1]) ax = plt.subplot(gs[0]) plt.setp(ax, xticks=(), yticks=()) plt.scatter(y_train, yhat, label=”Linear 1deg LASSO”, clip_on=False) plt.title(“CV avg score: {:.3}”.format(abs(scores.mean()))) plt.xlabel(“True car price”) plt.ylabel(“Predicted Car Price”) plt.plot(range(6), label=”perfect prediction”) #plt.xlim((min(y), max(y))) #plt.ylim((min(yhat), max(yhat))) plt.legend() ax = plt.subplot(gs[1]) ypos = np.arange(len(var[1:])) plt.barh(ypos, model.coef_, align=’center’) plt.yticks(ypos, var[1:]) ax.yaxis.tick_right() plt.title(“Coefficient Loadings”) plt.xlim([-1,1]) plt.tight_layout(pad=1.9) #print model.path(X,y)[1] fig, ax=plt.subplots(ncols=2, figsize=(15,7)) print -np.log10(model.alpha_) ax[0].plot(-np.log10(model.path(X_train, y_train)[0]), model.path(X_train,y_train)[1].T) ax[0].legend([str(i) for i in range(9)], loc=0) ax[0].axvline(x=-np.log10(model.alpha_), ls=’–’) ax[0].set_title(“Coef path for -log10(alpha)”) #ax[0].set_ylim((-5,5)) ax[1].plot(-np.log10(model.alphas_), model.mse_path_) ax[1].axvline(x=-np.log10(model.alpha_), ls=’–’) ax[1].set_title(“MSE on “+str(ncv)+” folds for -log10(alpha)”) The following code compares the prediction performance of LASSO against OLS. #import the test data test = np.genfromtxt(“dat_test.txt”) print test.shape test_scaled = scaler_func.transform(test) Xt = test_scaled[:,1:] #print test[:,1:].mean(axis=0) yt_scale = test_scaled[:,0] yt = test[:,0] 6 fig, ax = plt.subplots(ncols=2, figsize=(12, 6)) # First the Linear OLS yhat_scale=lin_reg.predict(Xt) yhat = yhat_scale*y.std()+y.mean() ax[0].scatter(yt, yhat) ax[0].plot(range(100000)) residual = np.sqrt(np.sum((yt-yhat)**2)) ax[0].set_title(“OLS Residual: {:.3}”.format(residual)) #Now the LASSO yhat_scale=model.predict(Xt) yhat = yhat_scale*y.std()+y.mean() ax[1].scatter(yt, yhat) ax[1].plot(range(100000)) residual = np.sqrt(np.sum((yt-yhat)**2)) ax[1].set_title(“LASSO Residual: {:.3}”.format(residual)) fig.tight_layout() 7
    Attachments:
    3164850_1_2871447-1-hw4-2.pdf

  • 1. What is Design Thinking? 2. What are the benefits of Design Thinking? 3. What are the…

    1. What is Design Thinking? 2. What are the benefits of Design Thinking? 3. What are the criticisms of Design Thinking? 4. In which context(s) might application of Design Thinking be useful?
    Attachments:
    3165644_1_2872297-1-busm4742-design-thinking-for-business—assessment-1-reflection.pdf

  • I am ensuring you will follow the description of assingment throughlyPlease let me know if you…

    I am ensuring you will follow the description of assingment throughlyPlease let me know if you have any questions or concernsPlease strictly follow the assignment descriptionReference must be in apa styleFollow the attached sample to do the assignment and don’t copy it
    Attachments:
    3166834_1_fwdattachedthefiles.zip

  • Multiple Choice Question 9: Which of the following is NOT true regarding Joshua Greene’s MRI…

    Multiple Choice Question 9:
    Which of the following is NOT true regarding Joshua Greene’s MRI research investigating brain activity in relation to the Trolley Experiment?
    a. According to Greene, only decisions reached by the part of the brain associated with rational decision-making can be considered moral.
    b. According to Greene, competition between different systems within the brain may lead to our human conceptualization of morality.
    c. When people are presented with Version 1 of the Trolley Experiment, the part of the brain associated with rational decision-making is activated.
    d. When people are presented with Version 2 of the Trolley Experiment, a less evolved part of the brain associated with emotional responses is activated.
    Note: Please tell me the correct answer.
    Multiple Choice Question 10:
    Which of the following is an example of
    an outcome-based morality argument in support
    of the following statement: The government should assure everyone has access to health care regardless of ability to pay.
    a. “Giving health care away to everyone will just encourage people to be irresponsible with their personal finances and personal health.”
    b. “Providing access to healthcare for everyone regardless of ability to pay will lower the disease burden and improve society for everyone.”
    c. “It’s simply unconscionable that people are forced to go without health care in a country as wealthy as the United States.”
    d. “It is a fundamental violation of my liberty for the government to take my taxes and use them to benefit someone else.”
    Note: Please tell me the correct answer. Attachments:
    3169480_1_1.Question.PNG
    3169480_2_2.Question.PNG

  • The Columbian Exchange involves many things . Diseases, flora and fauna, ideas and behaviors. As…

    The Columbian Exchange involves many things . Diseases, flora and fauna, ideas and behaviors. As the population becomes increasingly pluralistic each group -Indian, African and European- must negotiate and renegotiate on multiple levels. This complex process is a much a part of the Exchange as Smallpox or Oranges.
    Following your review of the attached article on Biological Exchange and Atlantic Demography and comment on the nature and importance of biological exchanges both positive and negative. Discuss lasting impact of the Columbian Exchange.
    250 works
    Attachments:
    3169528_1_infectious-disease-and-Atlantic-demography.pdf

  • The French and Indian War had profound consequences in North America. Heavily in debt after…

    The French and Indian War had profound consequences in North America. Heavily in debt after funding the War, Britain sought to limit further conflict with the Indians through limitation on westward expansion and an incfease in revenue from its Colonies. Discuss these issues.
    This War was truly a World War and in the aftermath reshaped Colonial North America in multiple ways. Please post your thoughts about the most significant result including the reasons for British post War policies and the reaction in the Colonies.
    Include in the discussion the effects of Imperial rivalries in North America leading up to the War and how they shaped the lives of colonists. Then how were things different after the War in the relationship between Britain and the colonies.
    250 words

  • The pivotal events of the years from 1763 to 1783 shaped an emerging “American ” identity,…

    The pivotal events of the years from 1763 to 1783 shaped an emerging “American ” identity, created new forms of governance , and redefined concepts of sovereignty. Historians have long debated the nature of that revolution – now is your opportunity to join in thr discussion.
    from the end of the French and Indian war in 1763,, a growing discourse, inspired and shaped by Enlightenment ideas, began to coalesce around independencel and revolution.. Conversations centered by pamphlets and broadsides took place in homes, commons and Taverns. Consider the importance of Thomas Paine’s
    Common Sense on
    debate. Continue to discuss all aspects of the revolution.
    250 words

  • is the detailed outline of your plan but with a minimum of facts and information from three…

    is the detailed outline of your plan but with a minimum of facts and information from three peer-reviewed or other journal sources from the APUS library or Internet sites provided in this course. This is a minimum 3 pages of written copy or content. Also include title page, reference page, and use APA Style.