• Picture1

    In music personalization, listeners have a tendency to incline towards a single artist or if no similar songs available from the same artist listeners inclined towards listening songs from other artists have a similar style, language or from the artists who might belong to the same ethnic background. For example at mass, listeners may not like to switch the songs from Justin Bieber to Nusrat Fateh Ali Khan or from Skrillex to Alan Jackson. At Cepstra, we developed a pure Artificial Intelligence-based system that identifies and group artists with a similar style based on the information available on the world wide web.

    We have a collection of artists’ information, including their career, area of expertise, music albums and songs, mixes, and other music-related productions gathered from various sources throughout the internet.

    We executed an algorithm based on Latent semantic analysis, analyzing the relationship between a set of documents and the terms they contain by producing a set of concepts related to the materials.

    LSA can be mathematically shown as,

    Where,

    X_k = U_k \sum_k V_k^T

    X_k is matrix defining similarity(co-occurrence).

    U_kV_k^T are decomposition matrices for values k.

    The collections of crawled content are converted into a matrix with the importance of different concepts throughout the artists’ information catalog, The model decomposed into its constituent parts in order to make precise subsequent matrix calculations simpler using Truncated Singular-Value Decomposition. This matrix is further normalized to its unit norm and based on similarity calculations, we create multiple groups of similar artists and their similarity strength.

  • I have seen many instances of the code looking dirty with very long Switch statement or If elses. Even lot of googling didn’t give me proper answer on what should be the right design to avoid such long code. So here I have attempted to solve such type of codes in practice and create Enum based design to replace Switch statement.

    Suppose we have situation where we need to perform some operation using switch cases like below.

    //problem area
    public void perform(char input) {
        switch (input) {
            case 'X':
                performX();break;
            case 'Y':
                performY();break;
            case 'Z':
                performZ();break;
            default:
                System.out.print("do nothing...");
        }
    }

    and we have our class which contains required methods

    public class Actor {
        public void performX() {
            System.out.print("performing...X");
        }
        public void performY() {
            System.out.print("performing...Y");
        }
        public void perfromZ() {
            System.out.print("performing...Z");
        }
    }

    Now change the hierarchy of class Actor with the help of an interface IActor

    interface IActor {
        public void perform();
    }
    public abstract class Actor implements IActor {
    }
    class ActorX extends Actor {
        public void perform() {
            System.out.print("performing...X");
        }
    }
    class ActorY extends Actor {
        public void perform() {
            System.out.print("performing...Y");
        }
    }
    class ActorZ extends Actor {
        public void perform() {
            System.out.print("performing...Z");
        }
    }

    Now lets create an Enum and call it Action

    public enum Action {
        X(new ActorX()), Y(new ActorY()), Z(new ActorZ());
        private IActor actor;
        private Actions(IActor actor) {
            this.actor = actor;
        }
        public void perform() {
            actor.perform();
        }
    }

    Finally, simply replace the the code in our problem area with below code.

    //Solution Area
    public void perform(char input) {
        Action.valueOf(String.valueOf(input)).perform();
    }

     

  • Picture1_img

    -The article was written with the help of an intern working with me

    In music personalization, people tend to prefer a particular set of instruments over others. For instance, listeners may prefer a song with acoustic instruments like guitar and cello over electronically generated bass. For this purpose, we decided to dive into a branch of research that can distinguish between the songs containing a different set of instrument mixture and add this as a feature to the music recommendation system.

    After a brief research period, we recognized that a certain set of instruments, if played together, produces a frequency that is similar to the same set of instruments played in a different song.

    In other words, there seems to be a behavioral pattern that is followed when the same instruments are played together in different songs. This finding leads us to craft a code that can segregate these frequencies and help us improve the music recommendation system.

     

    The song is loaded and chunked into lumps of 10 milliseconds file. The individual files are processed with Fast Fourier Transform (FFT) to convert the chunk from a time domain to a frequency domain. Since there are multiple frequencies present in the frequency band we needed the find the maximum frequency and load it into a list to further process it down.

    To do this,  We study  FFT(Fast Fourier Transform) of the chunk of frequencies.

    To calculate the frequency in hertz

    X(k)=\sum_{n=0}^{N-1} x(n)^{*} e^{-i^{*} 2^{*} \pi  n^{*} k / N}

    When the frequency at every chunk is obtained, the task remains to segregate them to their respective frequency bands. We have given a summary of the theory on which we have based this research on.

    The deepness of music is actually the low range frequency which produces the frequency range from 20 Hz to 200 Hz. That means any song having a base feature like a free kick in a soccer match will have a low-frequency range. The low frequencies have a greater wavelength, as a result, it sounds thick and deep. This frequency range is produced by 

    Lower mid-range carries the musical bass in your song for example notes from a bass guitar, a low note in saxophone or a thick flute. You can think of it as the flooring of your music as it provides the heaviness to your music. This frequency range, as well as the higher mid-range, is produced by the surround of the diaphragm in a speaker.

    The treble part lies between 1000 Hz to 5000 Hz of the song and this where most of the magic happens. From high-pitched voice to the guitar solos this is the most important part of the frequency regarding the melody and therefore it is also known as the full range of presence. This frequency is also the result of the surrounding part in a speaker.

    This section of the frequency range above 5000Hz is the high pitched section. The bright music everyone talks about, that’s the outcome of the frequency in this range. The whistle and the sharp pieces of the triangle you hear in a piece of music belongs to this range. This frequency range is produced by a driver called tweeter in a speaker.

    At Cepstra we study music keeping these values in the base of the algorithm, and generate various human-understandable characteristic of the music. 

  • Since the last few years, the technology industry sees drastic changes in operations, Artificial intelligence and automation are the key focus of many organizations these days. Top-level meetings are full of jargon like Machine learning, Deep Learning, and automated solutions. With these changes in the trend of the market, it is also important to understand and absorb that research-based solutions required a different sort of management typically. From top to the bottom level of the hierarchy there’s a need to realize that their previous assumptions with technology products are up for a test. Some significant methodological adaptations involved while managing artificial intelligence-based solutions that I am discussing here,

    Understand the probabilistic aspect of solutions, so here’s the first major hard block. Machine learning is not engineering either its solutions conclude that way, Machine Learning always and always works on some probability, that sometimes are calculated in terms of Precision and Recalls of the output. There are many different ways to calculate the accuracy of machine learning solutions like confusion matrix, F1 measure, G measure (Fowlkes–Mallows), Matthews correlation coefficient, etc. It’s important to note here that if your solution is giving 80% accuracy that does not means it is only going to act on 80% of inputs and ignore rest 20%. But since real-world applications required outcome for each input, you may want to code for fallbacks for inputs. Now that’s visible to code for fallbacks, what’s important here is the accuracy measured for a particular class of data, you will have to make sure that this accuracy of 80% covers maximum tonnage of your inputs.

    We all understand the fact that Machine learning is not software engineering, the team of Machine learning experts or some preferred to be called Data scientist is also different in many aspects. Remember there’s no fix programming language for Machine learning some algorithms work better when coded in python, some work better if coded in other programming languages like R or Scala. So unlike software engineering, you should not want to restrict your research development to a specific programming language. The outcome of your machine learning research development can be a combination of R scripts, Python notebooks or some other script files it then needed to be code with the help software engineers to complete the software application.

    Since machine learning is newer when it comes to available helping softwares, and during the development period experts need to analyze an enormous amount of data (sometimes in terabytes), it tends to take more time than traditional software deliveries. It’s often considered non-deterministic when you try to finalize its delivery timelines. So you may want to plan your deliverables to other stack holders keeping this fact in mind.

    Another aspect that needs to factorize is, there’s no fixed architecture or methodology a machine learning development would follow, it depends on the statistical compatibility of the data under analysis. So as you uncover the information layers of the data that are being analyzed, you discover the possible approach for the development. The step by step approach and validations on each phase could be a possible approach that can be acquired when you are managing timelines for such application development. Since this is important for the business to gain confidence in the Application, delivery of a working proof of concept could be beneficial.

    In the current scenario, not all problems can be solved by Machine learning efficiently. But the field is so promising, most of the marketing experts convince their clients that Machine learning is some sort of magic of mathematics that can do all the stuff which is being done by humans. In theory that seems possible but practically machine learning needs to mature to that level of confidence. There are many road blocks which tend to divert the complete flow of the development. First or for most important aspect is the structure of the data that’s under analysis for the problem statement. In my experience, data that are being used by many experts during the algorithms evaluations is of excellent quality, or easy to draw statistic inferences, but while solving real-world problems, the actual information could be hidden under the unrealistic layers of statistical inferences. Since the information in available data is a base of any machine learning algorithm it’s highly important you capture meaningful data for your analysis.

    At last, we all know Artificial intelligence technologies have enormous potentials that cannot be easily quantified. The technology leaders supporting business with their top-notch understanding of software engineering would need to support the very nature of such particular solutions. In some cases, managers might need to be vigilant about the idiosyncrasy of business while adapting such technologies. Since artificial intelligence is just started its journey with business, the technical managers leading the effort to solve problems need to embrace the caveats of this pioneer in computer science technologies.

  • Adding logs to code  or logging requests-responses  in any application has become an essential part of programming these days. Nearly every software application contains TBs of log files. Often programmers take logging for granted because of easy logging frameworks like slf4j, log4j. We hardly worry about the role of logs in our application performance.

    Logging is indeed important but we need to keep in mind the extent of its usage. So lets discuss how much logging is healthy for a code. Here I have created a small code exercise to identify difference in the method execution time using methods containing log and a plain method execution.

    I have used Google Caliper for micro benchmarking my methods and Log4J for adding logs to the code.

    import com.google.caliper.Runner;
    import com.google.caliper.SimpleBenchmark;
    import org.apache.log4j.Logger;
    
    public class LoggingBenchMark extends SimpleBenchmark {
        final static Logger logger = Logger.getLogger(LoggingBenchMark.class);
    
        public static void main(String[] args) throws Exception {
            new Runner().run(
                    LoggingBenchMark.class.getName()
            );
        }
    
        private static final int SET_SIZE = 100000;
    
        public void timeWithoutLog(int reps) throws InterruptedException {
            for (int i = 0; i < reps; i++) {
                for (int j = 0; j < SET_SIZE; j++) {
                    try {
                        performSomething(j);
                    } catch (Exception e) {
                    }
                }
            }
        }
    
    
        public void timeWithPlainLog(int reps) throws InterruptedException {
            for (int i = 0; i < reps; i++) {
                for (int j = 0; j < SET_SIZE; j++) {
                    try {
                        logger.info("testing logs adding here");
                        performSomething(j);
                    } catch (Exception e) {
                    }
                }
            }
        }
    
        public void timeWithLogExecively(int reps) {
            for (int i = 0; i < reps; i++) {
                for (int j = 0; j < 10000; j++) {
                    try {
                        logger.info("testing logs adding here");
                        performSomething(j);
                    } catch (Exception e) {
                        logger.error("exception in method : {}",e);
                    }
                    logger.debug("debug exception in method");
    
                }
                logger.info("some more logs");
            }
        }
    
    
        public void performSomething(int number) {
            if (number / 100 == 0) {
                throw new RuntimeException();
            }
    
        }
    }

    Just copy and run this code on your local, you will see the difference in the method execution time with log and without log is more than  2500%. With method performance, excessive logging also affects CPU usage for file I/O and the server space too.

    Logging application flows is necessary but overuse of logs to code flows has its drawbacks. Some ways of keeping logs to a minimum are by having a proper log level configured in application, avoiding the use of calculations/fetching data in the logging  statements.