Posts

Showing posts from August, 2018

[100 Days of ML Code] OneHotEncoder

One Hot Encoding is process by which categorical variables are converted into a form that could be provided to ML algorithms to do a better job in prediction. Normally, we will have a dataset of: ╔════════════╦════════╗ ║ CompanyName║ Price ║ ╠════════════╣════════║ ║ VW ║ 20000 ║ ║ Acura ║ 10011 ║ ║ Honda ║ 50000 ║ ║ Honda ║ 10000 ║ ╚════════════╩════════╝ Many ML algorithms cannot work with label data (as a string) directly. Therefore, we need to convert these labels into some numeric value: ╔════════════╦═════════════════╦════════╗ ║ CompanyName Categoricalvalue ║ Price ║ ╠════════════╬═════════════════╣════════║ ║ VW ╬ 1 ║ 20000 ║ ║ Acura ╬ 2 ║ 10011 ║ ║ Honda ╬ 3 ║ 50000 ║ ║ Honda ╬ 3 ║ 10000 ║ ╚════════════╩═════════════════╩════════╝ Now, 'categoricalValue' is a numerical value that represents the companyName. However, the problem with the ab

[Python] Python Equivalent of npm or rubygem

If you don't already have virtualenv installed, then install it globally with:  pip install virtualenv (or pip3 - for python3) Each Python project should have its own virtualenv installation. It's easy to set one up, just cd to your project's root and: python3 -m virtualenv env # creates env folder with everything you need Activate virtualenv:  source env/bin/activate Deactivate virtualenv: deactivate Now, any interaction with pip is contained within your project. Run  pip install package_name==version  for each of your dependencies. They are installed in ./env/lib/python3.x/site-packages/ When you want to save your project's dependencies to a file, run: pip freeze > requirements.txt You actually don't need -l or --local if you're in an activated project-specific virtualenv (which you should be). Now, when you want to install your dependencies from requirements.txt, set up your virtualenv, and run: pip install -r requirements.txt T

[Testing] Getting Started with Software Testing

Software Testing: is an investigation conducted to provide stakeholders with information about the quality  of the software product or service under test (SUT). Can provide an objective, independent view of the software to allow business to appreciate and understand the risk of software implementation. aims to execute a program or application with the intent to find software bugs. is an iterative process as when one bug is fixed, it can illuminate other, deeper bugs, or can even create new ones. In general, they aim to make sure component of system under test: meets requirements that guided its design and development responds correctly to all kinds of inputs performs its functions within an acceptable time is sufficiently usable can be installed and run in its indented environment achieves the general result its stakeholders desire. Defects and Failures Not all software defects are caused by coding errors. One common source of expensive defects is requirement g

[Unit Testing] Unit Test as a Bug Report

Image
When a test fails, that test failure report should be your best place to find what went wrong and give you clues to tracking the root cause . What's in a good Test Failure Bug Report? What are you testing? What should it do? What was the output (actual behavior)? What was the expected output (expected behavior)? (Example of good failure report) In the screenshot above, it's clear that we are testing 'compose()'. What is should do is to 'return a function'. It also shows expected, and actual, addition to the operator for our assert method. Resources: https://medium.com/javascript-scene/what-every-unit-test-needs-f6cd34d9836d

[Unit Testing] Best Practices of Unit Testing

1. Arrange, Act, Assert Think of each test as a hypothesis, and your test run as an experiment. Arrange; instantiate an object. Act; invoke a method and capture the reuslt. Assert; assert the hypothesis to prove it correct (or wrong). (You should 'tear down' after these 3 As) 2. One Assert per Test Method Don't have to be strictly followed, but a general guideline. Beginners have a tendency to try to test everything in one test method. But it'll be hard to pin down all the errors at once. 3. Avoid Test Interdependence Each test should handle its own setup and tear down. The test runner you use might execute several tests in parallel, and therefore, you don't want one test to depend on another test's state. While your test runner might execute your test in a particular order today, it might execute it in a different order tomorrow. To avoid confusion, just avoid test interdependence. 4. Keep it short, sweet and visible Resist the impulse t