Simulated Annealing (SA) is a probabilistic technique used for finding an approximate solution to an optimization problem. To find the optimal solution when the search space is large and we search through an enormous number of possible solutions the task can be incredibly difficult, often impossible. Even with today’s modern computing power, there are still often too many possible solutions to consider. Therefore, we often settle for something that’s close enough to optimal solution when we may be not able to find the optimal solution within a certain time.
Category: Coding
Introduction Machine Learning: K-nearest neighbors and Perceptron Learning Algorithm
Machine learning is a subfield of computer science where computers have the ability to learn without being explicitly programmed. List of the machine learning task:
- Supervised: Approximation where the all data is labeled and the algorithms learn to predict the output from the input data (training, cross validation and testing sets). We have two types of supervised problems:
- Regression: When the output variable is a real value, such as “dollars” or “age”.
- Classification: When the output variable is a category, such as “cat” or “dog” or “Tumor benign” and “Tumor malignant”.
Regression vs Classification
- Unsupervised: Description where the all data is unlabeled and the algorithms learn to inherent structure from the input data.
- Clustering: A clustering problem is where you want to discover the inherent groupings in the data, such as grouping customers by purchasing behavior.
- Association: An association rule learning problem is where you want to discover rules that describe large portions of your data, such as people that buy X also tend to buy Y.
Best Practices of Java Singleton Design Pattern
Singleton Pattern
We have different approaches but all of them have following common concepts to implement Singleton pattern:
- Private constructor which restricts instantiation of the class from other classes.
- Private static variable of the same class that is the only instance of the class.
- Public static method that returns the instance of the class, this is the global access point for outer world to get the instance of the singleton class.
Where do you use the Singleton pattern?
Most of the scenarios, Singleton classes are created for resources such as File System, Database connections etc…
Continue reading “Best Practices of Java Singleton Design Pattern”
PHP Closure and Lazy Loading
What is the Closures?
Let’s define firstly what is the anonymous function? If you are a front-end developer and have worked with JavaScript, you should be already familiar with anonymous functions. These pretty useful to write short inline functions, define callback etc.
An anonymous function is a function that was declared without any named identifier to refer to it. Here is the PHP implementation of anonymous function:
<?php $anonymousfunctionReference = function(){ echo "Anonymous function called" }; echo $anonymousfunctionReference();
HTTP Cache Headers
HTTP caching can speed up web applications. It’s standardized and well implemented in all modern browsers and results in a lower latency app and improved responsiveness.
HTTP caching occurs when an item is fully cached for faster retrieval the next time the resource is required. The browser may choose to not contact the server at all and simply use its own local copies of web resources. There are many cache headers such as “Cache-Control”, “Expires”, “Last-Modified” and “ETag”.
Regular Expressions
What is a Regular expressions?
Regular expressions are patterns used to match character combinations in strings. In JavaScript, regular expressions are also objects. These patterns are used with the exec and test methods of RegExp, and with the match, replace, search, and split methods of String.
How to Write a Regular Expression Pattern
A regular expression pattern is composed of simple characters, such as /abc/, or a combination of simple and special characters, such as /ab*c/ or /Chapter (\d+)\.\d*/. The last example includes parentheses which are used as a memory device. The match made with this part of the pattern is remembered for later use, as described in Using Parenthesized Substring Matches.
Gradle build tool
Sharing my own experience with you on Gradle
Gradle is nice tool to build applications like Maven and ant since it brings best of Maven and ANT… One thing that I don’t like with Gradle is too slow! It is slowest one when compared with ANT and Maven but it is simplest one either 😉
Gradle may be future of building JAVA apps. One day, it might be more popular and will be replaced with Maven by many companies.
Gradle uses the “Groovy” programming language! Don’t panic! You don’t need to know Groovy in order to write build script in Gradle! You just need to understand the Groovy and that is it! However, if you wanna learn about Groovy then here is link for you: Gradle