Week 3 - What I learned
2021/04/20 to 2021/04/26
Overview
This week was full of new concepts in which I would like to go deeper. We read
about quantum physics and was a whole new world. We learned a new way of programming
using TDD. We also learned new tools for testing and text editing. Finally, we had
to do a movie recommender using our new knowledge.
Videos
Inventing on Principle
Things to note or learn:
- We sometimes need to live based on a principle.
- Creators need an immediate connection to what they're doing.
- You can discover anything if you can't what you're doing.
- It's important to try ideas as you think of them.
- Ideas need work.
- This guy has a great tool!
- We need to be able to see what we're doing.
- We need to try ideas as we think of them.
- We need to visual elements instead of imagining everything.
- Principle: Media creations tools are not only for software.
- Creators don't have the proper environment.
- We can see wrong things.
- We can fight things that aren't right.
- A lot of people invented things using this principle.
- These principles are contagious.
- Having a principle makes changes.
- It's a lifestyle, but it doesn't have to be yours.
- Can take time to find a principle.
- The principle is something that you believe.
- Find a guiding principle.
Discussion:
I didn't think of this before, maybe I'm just working without a principle.
Right now I don't have a principle... But as we can see in the video
there are ways to discover our principle. What I could do to find my principle,
is to be more observer, see what is happening, find a problem, find an activity
or task that people aren't doing properly or the best way, and that's what triggers
all. Now, when you find something like that, I'll try to believe in something...
work for something to improve that part. I think I could do something like this,
and finally, fight those things and that's how change begins.
Pale Blue
Two things to remember from this video. Number one, we don't have another place
to go, all the resources that we have to live in this universe are here with
use (up to now as we know). We have to be careful with our resources, take care
of the world and try to make it a better place. The other point is that we are
so little and fragile and... well.. let's try to be more humble, we are not that big.
The future of programming
Things to note or learn:
- Computers change quickly.
- There's like a resistance to new ways of working.
- The programming changed over time.
- Coding.
- Procedures.
- Communication between systems was a problem.
- Procedures didn't work for communication. Because the program couldn't know
where to start or which procedure to run.
- It's important to receive an immediate response.
- Sequential.
- Massively Parallel processor array.
- We are going to start programming using a cluster of the processor.
- Each processor does its things and calculations and communicates to others.
- Massively Parallel Hardware.
- No more threads.
- Don't forget that we can have new ideas of how programming.
- Not everything is figured out.
- We have to be open to new ways of thinking.
- We have to free ourselves, just accept that we don't know what we are doing,
and start once again to learn new things.
Discussion:
I find it very interesting how this guy tries to explain the problems and how
programming communities invented new ways and styles of programming and how
through time these ways of programming changed and improved. I liked the
explanation and what this guy is trying to say and the message.
Now, all of these things had to change because technology changes and faces new
problems and we have to create new solutions and this takes us to new languages
and technologies. It is difficult to offer new technologies and for communities
to accept them because they tend to resist change. This is the main problem that
I can see.
In my opinion, the main message of the presentation is that we are going to face
problems and that everything is not figured out. We are going to have new
challenges and we have to try to solve them, but if we don't try to understand
this then we are going to resist change and avoid new solutions. We have to be
open to new solutions, new technologies and be able to work on new things. As
this guy said, you accept that you don't know what you are doing and what's
coming and start once again and learn again.
Machine learning - Google
Things to note or learn:
- Machine Learning is a subfield of AI.
- Learn from examples and experience.
- Supervised Learning: create a classifier by finding patterns in examples.
- Steps:
- 1.Collect Training Data
- 2.Train classifier
- 3.Predict
- 4.Visualize?
- Columns are not called columns. Its name is Features.
- Labels: Are the output we want.
- Decision tree.
- A Decision tree is easy to understand and visualize how they work.
- Sklearn has multiple datasets predefined.
- Testing is also important here.
- Having a good dataset creates a good classifier.
- To have a good dataset you should also have good features.
- The features should tell you something. (Should be useful)
- But you should have multiple features, this important too.
- Think of the number of features you need to get a great classifier.
- Useless features can hurt the classifier.
- It's a good practice to remove highly correlated features.
- Features should be easy to understand.
- We can verify our models if they work properly.
- Divide our dataset into two parts, the training, and the test data.
- We train the model then verify if it works with the test data. Using the labels.
- There are different algorithms for classification.
- KNN algorithm

- An object is classified by a plurality vote of its neighbors, with the object being
assigned to the class most common among its k nearest neighbors
- This uses Euclidean distance.
- Neural Network
- In images. You don't need to extract features manually.
-
Instead, you can use the raw pixels of the image's features and the
classifier will do the rest.
- The classifier we'll be using is called a neural network.
- We also need the training dataset and the test one.

- Tensorflow can help us!.
- Handwritten digits images work similarly.
- When we're working with images, we use the raw pixels as features.
- CART
- CART stands for Classification and Regression Trees.
- The representation for the CART model is a binary tree.
-
Each root node represents a single input variable (x) and a split point
on that variable (assuming the variable is numeric).
-
The leaf nodes of the tree contain an output variable (y) which is used to make a prediction.

- We have to prepare the data.
- Feature engineering
- Feature engineering is the process of using domain knowledge to extract features from raw data.
- This can help our algorithms or predictions improve their performance.
- Check a tool called weka.
Moonshot Thinking from Astro Teller and inside Google X
Things to note or learn:
- Value trying things.
- Value the quality of the experiment.
- Pick big problems.
- Search for the problem.
- Search the problem first, not the solution.
- Google X are guys just giving crazy ideas.
- The goal of google X is to find great big problems.
- Then they try to find a big and crazy solution.
- Solutions that nobody has ever tried yet.
- They start building the idea with no worries about budget.
- Innovation is the key.
- They run experiments. They learn.
- Here they are creating knowledge.
- Moonshot Thinking is when we choose a huge problem and propose to
create a radical solution to the problem using disruptive technology.
- It is about the quality of experiments not the quality of the outcome
- To make a ton of progress we have to go through a ton of failures.
- Embracing failure. Fail fast.
Discussion
In this part what I get most is the part of being constantly experimenting and
learning things. I think by doing this you have two outputs. The first one
is knowledge, if you try and fail then you are learning, and that's how I like
to learn! by doing things by myself. The other one is innovation, if one of
these ideas works then you have a new product that no one tried or invented before.
Also, I liked the freedom of doing things and coming up with new and crazy stuff.
In my opinion, letting people imagine crazy and new stuff is a motivator for
creativity and this is where innovation and new products are born. I wished
we could all work like that.
La mejor presentaciĆ³n de tu vida
Things to note or learn:
- We like modeling.
- Our presentations are important.
- They make an impact on other people.
- We should change the focus of the attention.
- We should focus on the content.
- Make people think.
- Make people feel.
- Flow point. Brain with minimum effort do a lot of things.
- Contribute something useful and new.
- Start by saying why it is useful.
- Less is more. Present something simple, simply by yourself.
- Show something that has order. General to particular and vice versa.
- Structure the topic.
- Tight the concept. Association.
- Participation of the audience.
- Ask your audience.
- Encourage participation.
- Use images.
- Use objects.
- Rhythm is important. Talk loud or high, fast or slow.
- Cast the emotion.
- The next presentation is going to be the best of your life, add new things.
Discussion
In this video, I learned tools to make better presentations. There are things
that I would like to improve in my presentations.
The first thing that I can do is to cast the emotion that I'm feeling when
I'm speaking, I could be more expressive. I want to do this because I want
people to feel something. Second thing is to try to interact with the audience,
ask questions, play with them or use them as an example, something like that.
Use different tones and volumes in my voice to create a differentiation in ideas.
Finally, I think to know this is important because we need to communicate ideas.
The last thing that I'll add is having feedback could also help us and remember
that we will always keep working to improve our presentations.
Quantum computers explained, Google and NASA's Quantum Artificial Intelligence Lab and
Double Slit Experiment
Things to note or learn:
- Well... this like a new definition to me. A transistor is just an electric switch.
- Transistors are so small!
- Quantum computers use qubits which are also two values (1 and 0) or both of them.
- Superposition is like things being ghosting on each other. So, it can a 0 or a 1 or 1 and 0.
- Quantum entanglement. Are still strongly related to each other, even though they can be a vast distance apart.
- Quantum computers are used in IT security. Can find the secret key from the public key.
- Quantum computers are also used in simulations.
- Multiverse exists.
- Tunneling is the slippage between universes.
- Quantum computers incorporate all of these theories in information processing.
- They want quantum computers to solve optimization problems.
- We have a lot of data. That's the problem.
- An observer... can change the behavior.... but how?
Discussion
About these videos, I didn't understand all of the videos... but what I can get
is that computation is changing and this is becoming more powerful. In this case,
is using Quantum science to process the information, and is a whole new change
because the information can be represented in new ways. Everything is changing
and is exciting how they are creating a new future.
This is the example that Bret Victor gave us, that things are going to change.
I see security changes, some algorithms are going to turn obsolete because
is going to be so easy to crack or brute force them. This one of many consequences
that I see. But, the point here is that we have to be open to new things and we
are going to start once again, destroy what we have and create a new mechanism in
multiple areas.
What Got You Here Won't Get You There: How Successful People Become Even More Successful,
Things to note or learn:
Discussion
There are a couple of things that I take with me in this video, but I just want
to mention how interesting and fun was this presentation. I would like to read
the book, I find it interesting how this guy presents the stuff and how it makes
the audience be part of the presentation by making them participate.
One of the points that made me realize a lot of things is that if someone doesn't
want to change, is not going to change. I mean change starts within one, not on
other things, you are going to change because you want to change, not because someone
tells you. We also have to understand that we can't change people, we are going to
lose our time with someone who doesn't want to change. We can help people to change
and I think we can begin by having good communication, let them know things.
The other point, that, in my opinion, is really important is that we have to be
humble towards others. Is true what this guy says, we can learn new things from
others and we could even be coached by somebody else. We also need to understand
that we are not superior and we can learn from people that we think aren't prepared
enough. This is a big mistake, let's try to learn from everyone and listen, I
think others have different ways of seeing things and interesting histories.
To finish this part, I like the title of the book. I think is a book about how
to keep improving ourselves. Once again we have to be humble and accept that
we aren't perfect and will never be so keep learning things, find the way to
know which parts could you improve, and finally really work on that, really do it.
Measure for Measure: Quantum Physics and Reality and
The Quantum Conspiracy: What Popularizers of QM Don't Want You to Know
Things to note or learn:
- Oh...(:O) the double-slit experiment is the prove of Quantum Physics' existence.
- Wave phenomenon happening.
- The wakes of the electrons are waves of probability.
- Yes!, the quantum paradigm changed everything we knew.
- Quantum goes against "Reality"
- This kind of thing is to answer how the world works.
- Quantum mechanism has an equation but could have a measurement problem.
- The observers have a fundamental role.
- Maybe our measurement tools aren't prepared enough to do that job.
- Outputs could change the way we think about phenomenons. Because the observer and
the outputs are part of the story.
- As I can understand there is a particle and the waves affect how the particle moves.
- The particle is guided by the wave.
- Because the wave has a structure we can get patterns.
- There are a lot of ideas to solve the measurement problem.
- In the quantum world, the measurement instrument is also in position. So the particle
was here and the measurement device found it there.
- In the many-worlds approach the particle lands in different positions but
we are going to see only one because the measurement instruments detect it there.
- The worlds are always there!
- There is an equation for this...
- The many-worlds all things can happen differently, but we can only see one.
- I know that there a lot of copies of me but I don't know who I am.
- Theory of everything happens
- Spontaneous collapse. Change the equation depending on the situation.
It depends on the measurement.
- If the situation changes the phenomenon is different so we have to measure
it differently.
- Makes different predictions.
- Qbism is about probabilities, the probability is about my belief.
- The Quantum States encodes an experiment on Agent's expectations for the experimental outcome.
- You take past variables to make predictions.
- Qbism could only be a tool. Is too philosophical.
- Maybe in 100 years, we are going to have an answer.
- No conspirancy :c
- "Quantum mechanics obeys the law of conservation of weirdness".
- What does it mean to 'measure' something?
- Measurements are consistent across space and time.
- These are after all very small particles and very delicate systems and so
maybe it's just physically impossible to make a measurement without disturbing
the system. That's what I thaught about the experiment!!!
- An observer works as a trigger the actions is going to happen.
- When an aspect of one photon's quantum state is measured, the other photon
changes in response even when the two photons are separated by large distancess
- Quantum mechanics: All wave equations have continuous time-reversible dynamics.
- That gives you the probability of measuring a particle at this position X at
a time T.
- There are a lot of equations.
- Multiple universes are just as tenable, according the math, as zero universes.
Discussion
A lot of stuff going in here! Well, I didn't understand everything and I'm not
an expert in that stuff. What I can notice is that science is trying to
improve and is trying to find new things that could change the way we live.
Also, what I can see is ta scientists are also having issues and that are
striving to get an answer. Once again we have to be open to new changes not
only in technology but in how we see the world.
What I also take is that we don't understand anything and that the most famous
scientists knew this and that's what motivated them to discover other world
and other forms in how life works. Let's take this with us, what we see is not
the reality and that reality could not be real. Let's just live with that.
Lastly, just to point out that computers are involving using these crazy concepts
and we don't know what awaits for us. In any case, we just need to be open to
new stuff and relearn anything needed. I think that this could affect our lives
in the distant future if new information comes out. If computers can change our
lives and problems too.
Creating Movie Recommendation for Amazon Movies users
This week we are going to build a Movie Recommendation app, but to do this
we have to learn new things. Let's go!
First of all, let's see a little example.
Creating a User-Based Recommender in 5 minutes
Link: Here
Here, we start by seeing the data set which is a user id related to an item, in
this case, could be a movie, and the strength of the relation. Now the important
here is how to do the recommendations. What we need to do is to compute
recommendations for other users we are going to search users with similar tastes
and pick the recommendations from their items. To find those users the model has
to do it by their interactions. To compute this the model is using correlation
coefficient with the interaction data. Now, you have users with similar tastes.
Using the 'neighborhood', the model, and the similarity now you can make recommendations.
We need that verify that indeed is giving a good recommendation. This model is
going to take 90% of the dataset as a training data set and the other 10% as the
test set. In the example, we can see how to build that piece of code and do the test.
The important thing here to note is that it is using the correlational coefficient to
do recommendations and A/B to test it.
Now we have to develop this app using something called Test Driven Development.
Let's read about it!.
Test Driven Development
This how you can do Test Driven Development:
- Think about what you have to do.
- Think about how to test it.
- Code a test and make it fail.
- Write the code to pass the test.
- Run all the tests and pass all of them.
- Refactor or remove duplication.
- Run all the tests and it should be passing
- Repeat of all the steps until you have nothing to code or test.
Well, there are some advantages from coding like this.
- Code is easier to reuse. Because it has 2 users (user and test).
-
The "remove duplication" phase forces one to examine code for latent
abstractions that one could express via virtual methods and other techniques
that naturally make code more extendable.
- Re-use is good.
- You may discover patterns in your code.
- Test code is easy to write.
- Code tends to be less coupled. Effective unit tests only test one thing.
- UnitTests stand as canonical & tested documentation for objects' usage.
Developers read them and do what they do in production code to the same objects.
This keeps projects annealed and on track.
- Test First Design forces you to really think about what you are going to do.
- Help find bugs in the application code
-
Testing helps is ensuring that the details of your algorithm remain the
same even if you refactor or add features.
I coded using this methodology and yes helps you a lot to think about what you are
going to do next, and also helps with not losing focus on the part you are working
on. Also makes you go back and refactor the code, so most of the time you are going
to have a clean code. In my opinion, using this methodology helps you a lot on
the code that you're building but also you'll have a lot of tests that work as
documentation.
Now that we know about the methodology we can now learn something about the little
pieces of code that do the tests.
UnitTest
First of all, is hard to define what is a "unit". In OOP tends to be a class in
functional maybe a function. This is where the discussion begins whether the unit you're
testing should be sociable or solitary.
Sometimes you a class needs some functionality from other classes; can we consider
this as a "unit"? No, not all unit testers use solitary unit tests. Using the
sociable test didn't lead to problems at all. So, we can call a sociable test,
unit test. Because you are testing the behavior of a single unit (with multiple classes).
There's another discussion about the speed. But I just want to point out some
things that could be useful:
- A unit could be sociable or solitary.
-
Testing the functionality of a unit that is using multiple classes shouldn't
be affected.
-
We can write a test assuming that other classes work properly.
-
You may not run all the unit tests, you can run only the ones that you're
working in.
-
If you are using Continuous Integration you should run a test suite as part of it
-
Test suites should run fast enough that you're not discouraged from running them frequently enough.
Don't worry about too much for seconds.
-
When they detect a bug there's a sufficiently small amount of work to look through that you
can find it quickly.
Now that we know about unit testing we can look to a framework to do this..
Xunit
XUnit is the family name given to bunch of testing frameworks that have become
widely known amongst software developers. The name is a derivation of JUnit,
the first of these to be widely known. Basically, that's the definition.
The main focus is to make it easy for developers to define the tests using their
regular Smalltalk environment, and then to run either a subset or a full set
of tests quickly. Later on, this became Junit. JUnit introduced the red/green
bar progress indicator. The article is more of the history of the development.
Let's take the important parts:
- X-Unit is a testing tool.
- It's easy to use.
- We can find assertions.
- An assertion is something that you can predict that is going to happen.
- JUnit is the unit tester for java.
- We can run all or a part of the tests.
- We can see a progress bar.
Now that we understand some basics, we can now go and lear what is Stub and a Mock.
Mocks Aren't Stubs
The term 'Mock Objects' has become a popular one to describe special case
objects that mimic real objects for testing.
We commonly confuse mocks with stubs. These are the differences:
On the one hand there is a difference in how test results are verified: a
distinction between state verification and behavior verification. On the other
hand is a whole different philosophy to the way testing and design play together,
which I term here as the classical and mockist styles of Test Driven Development.
The article is giving two examples of testing I'll try to describe them.
Regular Tests
These are the commons tests, the conventional JUnit tests.
It follows a four-phase sequence: setup, exercise, verify, teardown. The setup
method is where you create the objects. We create the objects and the asserts
are verifying that the objects did the correct thing. In this case, we don't
have to call the teardown, the garbage collector is going to do everything for us.
Here the style is state verification, we verify that everything is doing everything
properly. Asserts here are important!.
Tests with mock objects.
Let's see this example, in here the author is using jMock library for defining
mocks. jMock is a java mock object library.
Now we can see the example and some differences. First of all, the start is divided
into the data and expectations, the data part sets up the objects we are interested in working with,
the second part of the setup creates expectations on the mock object. The expectations
indicate which methods should be called on the mocks when the SUT is exercised.
The key difference here is how we verify that the order did the right thing in
its interaction with the warehouse.
With state verification we do this by asserts against the warehouse's state.
Mocks use behavior verification, where we instead check to see if the order
made the correct calls on the warehouse. We do this check by telling the mock
what to expect during setup and asking the mock to verify itself during verification.
Only the order is checked using asserts, and if the method doesn't change the
state of the order there's no asserts at all.
The other thing to note is that is not using the actual object's instance is
using an instance of a mock object. The important here is also the behavior.
The Difference Between Mocks and Stubs
Meszaros uses the term Test Double as the generic term for any kind of pretend
object used in place of a real object for testing purposes. The name comes
from the notion of a Stunt Double in movies.
- The stub uses state verification while the mock uses behavior verification.
- In order to use state verification on the stub, I need to make some extra
methods on the stub to help with verification.
- Mock objects always use behavior verification, a stub can go either way.
When do we use a Stub or a Mock?
-
If it's an easy collaboration then the choice is simple. Don't use a mock,
stub or any kind of double. Use a real object and state verification.
- If it's an awkward collaboration, use mocks and behavior verification.
Choosing Between the Differences
Besides the state and behavior verification there are other factors that we
can consider to choose between mocks and classical:
-
Driving TDD - Mocks: This is a very structured and controlled approach,
one that many people believe is helpful to guide newcomers to OO and TDD.
Classic TDD doesn't provide quite the same guidance.
-
Fixture Setup:
With classic TDD, you have to create not just the SUT but also all the
collaborators that the SUT needs in response to the test. Mockist tests,
however, only need to create the SUT and mocks for its immediate neighbors.
This can avoid some of the involved work in building up complex fixtures
-
Test Isolation: Mockist testers consider this to be a major issue; it
results in a lot of debugging in order to find the root of the error and fix
it. However, classicists don't express this as a source of problems.
-
Test Isolation: In essence classic xunit tests are not just unit tests,
but also mini-integration tests. As a result many people like the fact
that client tests may catch errors that the main tests for an object may
have missed, particularly probing areas where classes interact. Mockist
tests lose that quality. In addition you also run the risk that expectations
on mockist tests can be incorrect, resulting in unit tests that run green
but mask inherent errors.
-
Coupling Tests to Implementations:
With mockist testing, writing the test makes you think about the implementation
of the behavior, mockist testers see this as an advantage. Classicists,
however, think that it's important to only think about what happens from
the external interface and to leave all consideration of implementation
until after you're done writing the test.
Coupling to the implementation also interferes with refactoring, since
implementation changes are much more likely to break tests than with classic testing.
-
Design Style
To finish with this section we need to understand the context in which we are
working to make a decision. Also, there is no better, they are only tools and
they offer different solutions depending on the problem. Sometimes you need to
use a mock when you are also testing behavior and it's really important to consider
the other stuff that could be affected. But, you can always test with a regular
framework and objects. In my opinion is important to have tested any kind of
tests rather than no having something. Now we are going to learn this and we
can use this in our development. Like the author said, you can just give it a
try and see go it goes, but remember they are not the same and they cove specific
and different needs.
This is what we are going to do, try unit testing using objects not mocks, but
to do that we need a little thing more. The Java Tools.
Finally, let's read about the tool that can ease our work.
Java Build Tools: How Dependency Management Works with Maven, Gradle and Ant + Ivy
I kind of did a cheat sheet that I'm going to paste here.
Missing semester: Editors (Vim)
For this section I created my cheatsheet, I'm going to paste it here, I have to
learn how to use vim!
Missing semester: Version Control (Git)
Conclusions
I just want to point the most important points here:
-
We need to believe something and make it a principle, we can't fight things
that aren't right.
-
We don't understand the universe and maybe never... we are not that big,
let's stay humble
-
Not everything is figured out, we are going to face new problems and we
have to be ready for that.
-
Sometimes we need to make moonshot and fail and learn, this is a great way
for learning and innovating.
-
Things are changing, the world and we are changing so we have to be ready for
that too. We can't relax, there is still a lot of stuff to do.