2.In this problem and the next one, we’re going to make a very simple spam checker program by just looking
...
ooking at how likely a given email is to be spam based on the words it contains. In particular, in this problem we’re going to count how often words are present in spam emails within some set of training data (which here means a set of emails that have already been marked as spam or not spam manually).
We have already started to write a function spam_score(spam_file, not_file, word), which takes in two filenames, along with a target word (a lowercase string). Both filenames refer to text files which must be in the same directory as hw07.py (we’ve provided several such files in hw07files.zip). The text files contain one email per line (really just the subject line to keep things simple) - you can assume that these emails will be a series of words separated by spaces with no punctuation. The first file contains emails that have been identified as spam, the second contains emails that have been identified as not spam.
Since you haven’t learned File I/O yet, we’ve provided code that opens the two files and puts the data into two lists of strings (where each element is one line - that is, one email). You then must complete the function, so that it returns the spam score for the target word. The spam score is an integer representing the total number of times the target word occurs across all the spam emails, minus the total number of times the word occurs in not-spam emails. Convert all words to lowercase before counting, to ensure capitalization does not throw off the count.
View More
5.
Risk taking is an important part of investing. In order to make suitable investment decisions on behalf of their customers,
...
ehalf of their customers, portfolio managers give a questionnaire to new customers to measure their desire to take financial risks. The scores on the questionnaire are approximately normally distributed with a mean of 49 and a standard deviation of 14 The customers with scores in the bottom 10% are described as "risk averse." What is the questionnaire score that separates customers who are considered risk averse from those who are not? Carry your intermediate computations to at least four decimal places. Round your answer to one decimal place.
View More
6.1) Employees in 2012 paid 4.2% of their gross wages towards social security (FICA tax), while employers paid another 6.2%.
...
ers paid another 6.2%. How much will someone earning $34,000 a year pay towards social security out of their gross wages?
2) The population of a town increased from 3350 in 2005 to 4800 in 2010. Find the absolute and relative (percent) increase.
3)A company's sales in Seattle were $400,000 in 2012, while their sales in Portland were $295,000 for the same year. Complete the following statements:
a. Seattle's sales were
% larger than Portland's.
b. Portland sales were
% smaller than Seattle's.
c. Portland sales were
% of Seattle's.
4) A store has clearance items that have been marked down by 55%. They are having a sale, advertising an additional 30% off clearance items. What percent of the original price do you end up paying?
5) A friend has a 83% average before the final exam for a course. That score includes everything but the final, which counts for 15% of the course grade.
What is the best course grade your friend can earn?
%
What is the minimum score your friend would need on the final to earn a 75% for the course?
%
Give answers accurate to at least one decimal place.
6) A car is driving at 50 kilometers per hour. How far, in meters, does it travel in 3 seconds?
meters
Give your answer to the nearest meter.
View More
10.Hi! I got a 23 composite on my first ACT (30E 18M 22S 24R) I want to end up with
...
ch is a big jump. I need help with strategizing the science and reading sections so I can finish. I will also need that help with Math but I also need to learn a lot of content. How many hours would you recommend? I am willing to put in work outside of tutoring to take as many practice tests as possible. My twin brother got an 18 Composite and wants to raise it to a 29 C. Do you do group sessions?
View More
11.your boss at the bank finally gives you its current rough estimate of the bank’s average costs for each type
...
each type of classification error.
[Note that all bank models here include only profits and losses within three years of when a card is issued, so the impact of out-years (years beyond 3) can be ignored.]
Cost Per False Negative: $5000
Cost Per False Positive: $2500
For the 600 individuals that were automatically given cards without being classified, the total cost of the experiment turned out to be 25%*($5000)*600 or $750,000. This is $1,250 per event.
Only models with lower cost per event than $1,250 should have any value.
Question: What is the threshold score on the Training Set data for your model that minimizes Cost per Event? You will need this number to answer later questions.
Hint: Using theAUC Calculator Spreadsheet, identify which Column displays the same cost-per-event (row 17) as the overall minimum cost-per-event shown in Cell J2. The threshold is shown in row 10 of that Column. What the threshold means is that at and above this number everything is classified as a "default."
View More
12.your boss at the bank finally gives you its current rough estimate of the bank’s average costs for each type
...
each type of classification error.
[Note that all bank models here include only profits and losses within three years of when a card is issued, so the impact of out-years (years beyond 3) can be ignored.]
Cost Per False Negative: $5000
Cost Per False Positive: $2500
For the 600 individuals that were automatically given cards without being classified, the total cost of the experiment turned out to be 25%*($5000)*600 or $750,000. This is $1,250 per event.
Only models with lower cost per event than $1,250 should have any value.
Question: What is the threshold score on the Training Set data for your model that minimizes Cost per Event? You will need this number to answer later questions.
View More
13.These are the questions I need to answer
A researcher examines whether the clinically anxious individuals differ from people in
...
viduals differ from people in general in remembering threatening information. The memory performance of an individual for negative words was measured and was found to have a score of 48. The population average is 34 with a standard deviation of 9. At the 5% level of significance what should you conclude about whether clinically anxious individuals have a tendency to remember threatening words?
(a) Clearly state null and research hypotheses in terms of the mean scores on the memory performance on negative words, μ, of anxious individuals.
(b) What is the comparison distribution for the sample’s Z score?
(c) What are the cut-off values for a test with significance level 0.05?
(d) What is the observed Z score?
(e) What is your conclusion?
An educational psychologist was interested in whether children who grow up in bilingual settings have an advantage of distraction resistance compared with children in general. The distraction resistance test was administered to a randomly chosen child with bilingual upbringing background who was found to have a score of 69. The population average is 60 with a standard deviation of 3. Do children with bilingual upbringing background score higher on distraction resistance test than children in general? Use the 1% level of significance.
(a) Clearly state null and research hypotheses in terms of the mean scores on distraction resistance, μ, of children with bilingual upbringing.
(b) What is the comparison distribution for the sample’s Z score?
(c) What are the cut-off values for a test with significance level 0.01?
(d) What is the observed Z score?
(e) What is your conclusion?
View More
16.To gain experience with the operations involving binary search trees. This data structure as linked list uses dynamic memory allocation
...
list uses dynamic memory allocation to grow as the size of the data set grows. Unlike linked lists, a binary search tree is very fast to insert, delete and search.
Project Description
When an author produce an index for his or her book, the first step in this process is to decide which words should go into the index; the second is to produce a list of the pages where each word occurs. Instead of trying to choose words out of our heads, we decided to let the computer produce a list of all the unique words used in the manuscript and their frequency of occurrence. We could then go over the list and choose which words to put into the index.
The main object in this problem is a "word" with associated frequency. The tentative definition of "word" here is a string of alphanumeric characters between markers where markers are white space and all punctuation marks; anything non-alphanumeric stops the reading. If we skip all un-allowed characters before getting the string, we should have exactly what we want. Ignoring words of fewer than three letters will remove from consideration such as "a", "is", "to", "do", and "by" that do not belong in an index.
In this project, you are asked to write a program to read any text file and then list all the "words" in alphabetic order with their frequency together appeared in the article. The "word" is defined above and has at least three letters.
Note:
Your result should be printed to an output file named YourUserID.txt.
You need to create a Binary Search Tree (BST) to store all the word object by writing an insertion or increment function. Finally, a proper traversal print function of the BST should be able to output the required results.
The BST class in the text can not be used directly to solve this problem. It is also NOT a good idea to modify the BST class to solve this problem. Instead, the following codes are recommended to start your program.
//Data stored in the node type
struct WordCount
{
string word;
int count;
};
//Node type:
struct TreeNode
{
WordCount info;
TreeNode * left;
TreeNode * right;
};
// Two function's prototype
// Increments the frequency count if the string is in the tree
// or inserts the string if it is not there.
void Insert(TreeNode*&, string);
// Prints the words in the tree and their frequency counts.
void PrintTree(TreeNode* , ofstream&);
//Start your main function and the definitions of above two functions.
Sample Run
Please type the text file name: Lincoln.txt
Please give the output text file name: mus11.txt
You are done! You can open the file "mus11.txt" to check.
Press any key to continue
------------------------------------------------------------------------------------------------------------------------------------------------
lincoln.txt---
The Gettysburg Address
Gettysburg, Pennsylvania
November 19, 1863
Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in
Liberty, and dedicated to the proposition that all men are created equal.
Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and
so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate
a portion of that field, as a final resting place for those who here gave their lives that that nation
might live. It is altogether fitting and proper that we should do this.
But, in a larger sense, we can not dedicate -- we can not consecrate -- we can not hallow -- this ground.
The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add
or detract. The world will little note, nor long remember what we say here, but it can never forget what
they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they
who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great
task remaining before us -- that from these honored dead we take increased devotion to that cause for
which they gave the last full measure of devotion -- that we here highly resolve that these dead shall not
have died in vain -- that this nation, under God, shall have a new birth of freedom -- and that government
of the people, by the people, for the people, shall not perish from the earth.
------------------------------------------------------------------------------------------------------------------------------------------------
mus11.txt
1863 1
Address 1
But 1
Four 1
Gettysburg 2
God 1
Liberty 1
November 1
Now 1
Pennsylvania 1
The 3
above 1
add 1
advanced 1
ago 1
all 1
altogether 1
and 6
any 1
are 3
battle-field 1
before 1
birth 1
brave 1
brought 1
but 1
can 5
cause 1
civil 1
come 1
conceived 2
consecrate 1
consecrated 1
continent 1
created 1
dead 3
dedicate 2
dedicated 4
detract 1
devotion 2
did 1
died 1
earth 1
endure 1
engaged 1
equal 1
far 2
fathers 1
field 1
final 1
fitting 1
for 5
forget 1
forth 1
fought 1
freedom 1
from 2
full 1
gave 2
government 1
great 3
ground 1
hallow 1
have 5
here 8
highly 1
honored 1
increased 1
larger 1
last 1
little 1
live 1
lives 1
living 2
long 2
measure 1
men 2
met 1
might 1
nation 5
never 1
new 2
nobly 1
nor 1
not 5
note 1
our 2
people 3
perish 1
place 1
poor 1
portion 1
power 1
proper 1
proposition 1
rather 2
remaining 1
remember 1
resolve 1
resting 1
say 1
score 1
sense 1
seven 1
shall 3
should 1
struggled 1
take 1
task 1
testing 1
that 13
the 9
their 1
these 2
they 3
this 4
those 1
thus 1
under 1
unfinished 1
vain 1
war 2
what 2
whether 1
which 2
who 3
will 1
work 1
world 1
years 1
View More