Bayes theorem helps us to incorporate new evidences/information into our model.
Code from sklearn
from sklearn.naive_bayes import GaussianNB
Linear in the number of variables.
Naive Bayes assumes conditional independence across attributes and doesn’t capture inter-relationship among attributes.
Gaussian naive Bayes assumes continues values associated with each class are distributed in Gaussian fashion.
Even if the probability of one of the attributes given label becomes zero, the whole thing ends up being zero.
Maximum Likelihood :
Design that is more automated and require less maintenance is the standard.
Getters and setters:
Setters can be used for validation and constraining the value to be set to a particular range.
Getters can be used for returning default value, if the variable is not set yet or for lazy instantiation.
Can’t make objects out of abstract class. Abstract class can have some non abstract members.
Interface have only abstract methods.
- Can only have one instance of that particular class.
- President of a country, System in java.
- Private constructor, singleton using enum.
- @Singleton annotation.
- Difficult to unit test – why?
- Having a logic to return a particular subclass object, when asked for a class object.
- Abstract Factory:
- Separates object construction from its representation.
- Chess game initial setup.
- Copying/cloning the initial setup rather than creating the initial setup everytime you need it. Reduce redundant work.
- Copy a fully initialized instance.
- Link to code.
How to create objects?
Inheritance? Interface? etc.
How are different classes related?
How are objects composed?
- Match interfaces of different classes. helps to communicate.
- An object representing another object, like credit card as a proxy of bank account.
- Remote object and Home object(proxy).
- Reuse same objects by resetting values of the objects appropriately instead of creating new objects every time.
- Event managers, process, execute, group many steps into a single step.
- Add responsibilities to objects dynamically.
- Ex: adding different Toppings for different pizzas, adding discounts to different orders.
Interactions between different objects.
- Template method:
- instead of applications talking to each other, we use an enterprise service bus.
- Chain of responsibility:
- Passing a request through different objects.
- A way of notifying a change to a number of classes.
- This pattern is implemented in java.
- Subject extends Observable.
- Who wants to listen implements Observer and registers with the subject.
- change the implementation/strategy of an interface at a later point in time.
- Pass whatever implementation needs to be used as an argument.
- Encapsulate a command request as an object.
- java.lang.runnable threads are implemented like this.
- Adding new operations to a particular class without inheritance and wi
- Sequentially access the elements of a collection.
- Saving states of something as objects to restore them in future point of time if necessary.
- Undo/Redo operations.
Factory pattern :
Abstract Factory pattern:
Try to put state and behaviors in different classes.
Enable a class to be generic by making it disown the responsibility of defining an object in itself. Make other classes define the input object for it.
If you want to change the input object , you dont need to change the original class with dependency injection.
A spring container contains a set of objects or beans.
Identify what are assets and what are liabilities.
Increase asset column.
Don’t work for money, make money work for you.
Rich buy luxuries late.
Rich guys income statement and balance sheet.
How corporations help rich with taxes.
Corporations earn, spend and then pay taxes on the rest.
Individuals earn, get taxed and then spend.
Listing some assets:
- Businesses that do not require my presence.
- Stocks – Fortunes are made in new stock issues(new stocks are tax-free).
- Income generating real estate.
- Notes (IOUs).
- Royalties from intellectual property.
Dimensions of financial literacy:
- Understanding markets:
- The law:
The ideal random number generator is impossible. So, we usually have a pseudo-random generator which will be seeded by a number initially and then calculated subsequent random numbers using elements like current system time etc. For debugging stochastic programs, we have random.seed() in python which will generate the same sequence of random numbers again and again as we seed it with the same number.
- Random access.
- Fixed size.
- Not Random access.
- Not fixed size.
What we need is something that has random access and not fixed size.
Solution: Hash table
Uses a hash function to determine where to store a given key value.
Same hash function is used later to search for where a given key value is stored.
If the hash output of two keys point to the same location.
Solution: each location has a linked list of values.