🍐 我们总结了计量经济学代写中——R语言代写的经典案例,如果你有任何Econometrics代写的需要,可以随时联络我们。CoursePear™ From @2009。

Overview
In this individual project, you will work through various classification metrics. You will be asked to
create functions in R to carry out the various calculations. You will also investigate some functions in
packages that will let you obtain the equivalent results. Finally, you will create graphical output that also
can be used to evaluate the output of classification models, such as binary logistic regression.
Supplemental Material
 Applied Predictive Modeling, Ch. 11 (provided as a PDF file).
 An Introduction to ROC Analysis (provided as a PDF file).
 Web tutorials: http://www.saedsayad.com/model_evaluation_c.htm
Deliverables (60 Points)
 Upon following the instructions below, use your created R functions and the other stated packages
to generate the classification metrics for the provided data set. A write-up of your solutions
submitted in PDF format.
Instructions
Complete each of the following steps as instructed:

  1. Download the classification output data set (attached in Canvas to the assignment).
  2. The data set has three key columns we will use:
     class: the actual class for the observation
     scored.class: the predicted class for the observation (based on a threshold of 0.5)
     scored.probability: the predicted probability of success for the observation
    Use the table() function to get the raw confusion matrix for this scored dataset. Make sure you
    understand the output. In particular, do the rows represent the actual or predicted class? The
    columns?
  3. Write a function that takes the data set as a dataframe, with actual and predicted classifications
    identified, and returns the accuracy of the predictions.

Accuracy =

TP + TN
TP + FP + TN + FN

  1. Write a function that takes the data set as a dataframe, with actual and predicted classifications
    identified, and returns the classification error rate of the predictions.

Classification Error Rate =

FP + FN
TP + FP + TN + FN
Verify that you get an accuracy and an error rate that sums to one.

  1. Write a function that takes the data set as a dataframe, with actual and predicted classifications
    identified, and returns the precision of the predictions.
    Precision =
    TP
    TP + FP
  2. Write a function that takes the data set as a dataframe, with actual and predicted classifications
    identified, and returns the sensitivity of the predictions. Sensitivity is also known as recall.

Sensitivity =
TP
TP + FN

  1. Write a function that takes the data set as a dataframe, with actual and predicted classifications
    identified, and returns the specificity of the predictions.
    Specificity =
    TN
    TN + FP
  2. Write a function that takes the data set as a dataframe, with actual and predicted classifications
    identified, and returns the F1 score of the predictions.

F1 Score =

2 × Precision × Sensitivity
Precision + Sensitivity

  1. Let’s consider the following question: What are the bounds on the F1 score? Show that the F1
    score will always be between 0 and 1. (Hint: If 0 < a < 1 and 0 < b < 1 then ab < a.)
  2. Write a function that generates an ROC curve from a data set with a true classification column
    (i.e., class) and a probability column (i.e., scored.probability). Your function should return the plot
    of the ROC curve and the calculated area under the ROC curve (AUC). Note that I recommend
    using a sequence of thresholds ranging from 0 to 1 at 0.01 intervals.
  3. Use your created R functions and the provided classification output data set to produce all of the
    classification metrics discussed above.
  4. Investigate the caret package. In particular, consider the functions confusionMatrix, sensitivity,
    and specificity. Apply the functions to the data set. How do the results compare with your own
    functions?
  5. Investigate the pROC package. Use it to generate an ROC curve for the data set. How do the
    results compare with your own functions?

CoursePear™是一家服务全球留学生的专业代写
—-我们专注提供高质靠谱的美国、加拿大、英国、澳洲、新西兰代写服务。
—-我们专注提供Essay、统计、金融、CS、经济、数学等覆盖100+专业的作业代写服务。

计量经济学代写
计量经济学代写

CoursePear™提供各类学术服务,Essay代写Assignment代写Exam / Quiz助攻Dissertation / Thesis代写Problem Set代做等。