pwp-capstones's People
pwp-capstones's Issues
Code Feedback
Thanks for your submission. Overall, you did a good job. Most of this feedback are just recommendations.
1
As you're printing each author along with the average number of words in their note/intros, you write
print("Author: {}, average words per sentence: {}\n".format(person, str(get_average_sentence_length(names_texts[person]))))
Note that it is not necessary to cast the result of the call to get_average_sentence_length
to a string. The following accomplishes the same thing
print("Author: {}, average words per sentence: {}\n".format(person, get_average_sentence_length(names_texts[person])))
2
It will be better to move sections Creating The Definition for Our Model and Creating our TextSample Instances to a later point in your notebook since they cannot be executed in sequence at the moment.
3
In your implementation of frequency_comparison
, you first store the values of appearances and mutual appearances in a dictionary and then execute a sum operation over the dictionaries later. Although this works, it's unnecessary extra work. Since you see each value before storing it in the dictionary, simply keep a running sum of the appearances as you go along. This saves time. Here's a snippet of what the change could look like
appearances = 0
mutual_appearances = 0
# some code
if table1[element] > table2[element]:
appearances += table1[element]
mutual_appearances += table2[element]
else:
appearances += table2[element]
mutual_appearances += table1[element]
# the rest with similar changes
4
My final comment concerns the return statements in your get_average_sentence_length
and frequency_comparison
functions. Here they are
# get_average_sentence_length
return mean(num_words)
# frequency_comparison
sum(mutual_appearances.values()) / sum(appearances.values())
Although your code does not throw an error here, it can. You should make a habit of checking that a value is nonzero before dividing by it. In the first case, numpy
will return nan
if num_words
is an empty list and in the second case, you will get a zero division exception. In both cases, your program will exit at some point with an unhandled exception. You can avoid these issues by checking before dividing.
Score
Rubric Score
Criteria 1: Valid Python Code
- Score Level: 4
- Comment(s): The provided code runs without errors.
Criteria 2: Implementation of Project Requirements
- Score Level: 4
- Comment(s): You provide correct implementations for the required suite of functions within the scope of the assignment.
Criteria 3: Software Architecture
- Score Level: 3
- Comment(s): The code is organized in a reasonable way for the most part. I point out one place where reorganization is necessary in my second comment.
Criteria 4: Uses Python Language Features
- Score Level: 4
- Comment(s): You make good use of Python built ins to help you accomplish your work.
Criteria 5: Produces Accurate Output
- Score Level: 4
- Comment(s): Your output is well formatted and accurate.
Overall Score: 19/20
Please see my feedback for further comments.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.