0% found this document useful (0 votes)
7 views2 pages

O(n²) Algorithm Time Complexity & ML Insights

The document discusses the runtime of an O(n2) algorithm, calculating that it will take 100 seconds to run when n = 500 based on its scaling properties. It also explains the concepts of overfitting and underfitting in machine learning, suggesting regularization as a method to reduce overfitting. Finally, it describes features used in a text classification model for movie reviews and highlights accuracy, precision, recall, and F1 score as evaluation metrics.

Uploaded by

paneyip820
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

O(n²) Algorithm Time Complexity & ML Insights

The document discusses the runtime of an O(n2) algorithm, calculating that it will take 100 seconds to run when n = 500 based on its scaling properties. It also explains the concepts of overfitting and underfitting in machine learning, suggesting regularization as a method to reduce overfitting. Finally, it describes features used in a text classification model for movie reviews and highlights accuracy, precision, recall, and F1 score as evaluation metrics.

Uploaded by

paneyip820
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Question: An algorithm runs in O(n2) time.

If it takes 4 seconds to run when n = 100, how long


will it take when n = 500?

Answer:

An O(n2) algorithm’s runtime scales with the square of the input size.

Given,
Time at n = 100 is 4 seconds
Time at n = 500 is ?

Time500 = Time100 × (500 / 100)2

= 4 × (5)2 = 4 × 25

= 100 seconds

Final Answer: 100 seconds

Question: Explain informally the difference between overfitting and underfitting in a supervised
learning model. Suggest one method to reduce overfitting.

Answer:

When training a machine learning model, two common issues we might run into are overfitting
and underfitting. Overfitting is when the model tries too hard to be perfect on the training data. It
memorizes every little detail, even the random noise or quirks. Which means it struggles to
perform well on new, unseen data. It’s kind of like a student who memorizes answers for a
specific test but doesn’t really understand the subject, so they can’t handle different questions.

On the other hand, underfitting is the opposite problem. This happens when the model is not
trained enough to capture the real patterns in the data. It ends up performing poorly on both the
training set and any new data. Like a student who just skimmed through the material and didn’t
really learn anything deeply.

One practical way to reduce overfitting is by using regularization. A technique that helps the
model stay simpler and more general. Methods like L1 or L2 regularization add a small penalty
for using overly complex models (very large weights in the model). This encourages the model to
focus on the most important features and avoid getting distracted by the noise, making it more
likely to perform well on data it hasn't seen before.
Question: A basic text classification model assigns labels to movie reviews as "positive" or
"negative.” What features might such a model use, and what common metric would you use to
evaluate its performance?

Answer:

In a simple movie review classifier that decides whether a review is positive or negative, the
model looks at various features in the text to make its decision. One of the most straightforward
things it might use is the presence or frequency of certain words. For example, if a review
contains words like “amazing” or “terrible” that gives a strong clue about the sentiment.

A more refined method is TF-IDF (Term Frequency-Inverse Document Frequency), which helps
the model focus on words that are not only frequent but also meaningful across the dataset. The
model might also look at n-grams which are small sequences of words. So instead of just seeing
“good” it can notice phrases like “not good” which flips the meaning.

To see how well the model is doing, one common metric is accuracy. Basically, how many
reviews it labels correctly out of all the ones it sees. But accuracy isn’t always enough. If the
dataset has way more positive reviews than negative ones (or vice versa), the model might look
good just by guessing the majority label. That’s when metrics like precision, recall, or the F1
score come in handy they give a better picture of how balanced and reliable the predictions really
are.

You might also like