.Net, Machine Learning & AI

.Net, Machine Learning & AI

Introduction:

The fields of machine learning and artificial intelligence (AI) have seen remarkable growth and innovation in recent years. Industries are leveraging these technologies to enhance their applications and provide smarter, more intuitive user experiences. One such powerful toolset for developing AI and ML-driven applications is .NET. In this blog, we will explore the synergy between .NET, machine learning, and AI, along with a practical example that demonstrates their capabilities.

Artificial Intelligence:

Artificial intelligence is the simulation of human intelligence processes by machines, especially computer systems. In other words, artificial intelligence (AI), is the ability of a digital computer or computer-controlled robot to perform tasks commonly associated with intelligent beings. The term is frequently applied to the project of developing systems endowed with the intellectual processes characteristic of humans, such as the ability to reason, discover meaning, generalize, or learn from experience.

 AI applications include advanced web search engines (e.g., Google Search), recommendation systems (used by YouTube, Amazon, and Netflix), understanding human speech (such as Siri and Alexa), self-driving cars (e.g., Waymo), generative or creative tools (ChatGPT and AI art), automated decision-making, and competing at the highest level in strategic game systems (such as chess and Go).

Machine Learning:

Machine learning is a subset of AI, which enables the machine to automatically learn from data, improve performance from past experiences, and make predictions. Machine learning contains a set of algorithms that work on a huge amount of data. Data is fed to these algorithms to train them, and based on training, they build the model & perform a specific task.

Understanding .NET:

.NET is a versatile framework developed by Microsoft, designed to build a wide range of applications for various platforms such as Windows, web, mobile, cloud, and IoT. It provides a rich set of libraries, tools, and languages that simplify the development process, making it easier for developers to create robust and scalable applications.

Empowering Applications with Machine Learning and AI:

Machine learning and AI empower applications to learn from data, detect patterns, and make intelligent decisions. By incorporating machine learning algorithms and AI models into .NET applications, developers can create intelligent systems that can analyse vast amounts of data, gain insights, and automate tasks that were once manual and time-consuming.

ML.NET:

//Step 1. Create an ML Context var ctx = new MLContext();   //Step 2. Read in the input data from a text file for model training IDataView trainingData = ctx.Data     .LoadFromTextFile<ModelInput>(dataPath, hasHeader: true);   //Step 3. Build your data processing and training pipeline var pipeline = ctx.Transforms.Text     .FeaturizeText(“Features”, nameof(SentimentIssue.Text))     .Append(ctx.BinaryClassification.Trainers         .LbfgsLogisticRegression(“Label”, “Features”));   //Step 4. Train your model ITransformer trainedModel = pipeline.Fit(trainingData);   //Step 5. Make predictions using your trained model var predictionEngine = ctx.Model     .CreatePredictionEngine<ModelInput, ModelOutput>(trainedModel);   var sampleStatement = new ModelInput() { Text = “This is a horrible movie” };   var prediction = predictionEngine.Predict(sampleStatement);

ML.NET is a free, open-source, and cross-platform machine learning framework for the .NET developer platform. With ML.NET, you can create custom ML models using C# or F# without having to leave the .NET ecosystem. ML.NET lets you re-use all the knowledge, skills, code, and libraries you already have as a .NET developer so that you can easily integrate machine learning into your web, mobile, desktop, games, and IoT apps.

Practical Example: Sentiment Analysis with .NET, Machine Learning, and AI:

Let’s delve into a practical example to showcase the integration of .NET, machine learning, and AI. We will build a sentiment analysis application using these technologies, which can automatically analyse the sentiment (positive, negative, or neutral) of a given text.

Step 1: Dataset Collection:

To train our sentiment analysis model, we need a dataset that contains text samples labelled with their corresponding sentiment. We can utilize existing sentiment analysis datasets available online or create our dataset by manually labelling texts.

Step 2: Data Preprocessing:

Before training a machine learning model, it is essential to preprocess the data. This step involves cleaning the text, removing stop words, tokenizing, and converting it into a suitable format for model training.

Step 3: Model Training:

In this step, we employ a machine learning algorithm, such as Naive Bayes, Support Vector Machines (SVM), or Recurrent Neural Networks (RNNs), to train our sentiment analysis model. The .NET framework provides libraries such as ML.NET, which simplify the training and evaluation process.

Step 4: Model Integration:

Once the model is trained, we integrate it into a .NET application. Using the ML.NET library, we can load the trained model and make predictions on new text samples. This enables our application to automatically determine the sentiment of any given text.

Step 5: User Interface Development:

To provide a user-friendly experience, we develop a graphical user interface (GUI) using .NET technologies like Windows Presentation Foundation (WPF) or ASP.NET. The interface allows users to input text and receive real-time sentiment analysis results.

Conclusion:

The integration of .NET, machine learning, and AI opens up endless possibilities for developers to create intelligent and data-driven applications. In this blog, we explored a practical example of sentiment analysis, where we leveraged the power of .NET to train a machine learning model and built an application that can analyse sentiment in real time. This is just one example of how these technologies can be combined to create innovative solutions. As technology continues to advance, the collaboration between .NET, machine learning, and AI will play an increasingly pivotal role in shaping the future of software development.

References:

Microsoft Documentation: https://docs.microsoft.com/dotnet/

ML.NET: https://dotnet.microsoft.com/apps/machinelearning-ai/ml-dotnet

Satinder Singh

Software Dev Blog

A Complete Guide to Using Clover – A Code Coverage Tool

Quite often we come across situations in the software development industry where we ensure that every single feature is tested before a release, but we still find something broken once the application is released into production. It can be either due to a couple of testers not creating all the test cases required, or missing the execution of a couple of existing tests during the regression cycle. This can be either a manually tested regression suite or an automated suite, we still run into the same problem, wherein the so-called test coverage is 100%, but we still find something broken once released.

To ensure the entire application code has been covered as part of the testing process we can use the Clover code coverage tool. In this blog, I will be focusing on using Maven as the build tool and will be using a sample java spring application. So this is how the tool works.

Basically, when the project is built, all the classes in the project get instrumented and these instrumented classes get packaged as part of the jar/war file. To keep it simple, you can think of instrumentation as the Java classes being slightly modified, to track which lines of the class are being traversed when the application is used. Along with the instrumentation, the clover.db registry is created, where the project structure and the details of all the classes are stored.

Now when you deploy this jar/war file, the instrumented classes are deployed, and the clover coverage recorder files are created. These .db files store the coverage information of which lines of code have been traversed when the application is in use.

Now let us try it out on a sample application.

You can download any public sample application available on Github to try it out. I have downloaded this publicly available application from Github: https://github.com/joakim666/spring-boot-spring-loaded-java8-example

Steps:

1. Add the below profiles section in the pom.xml of this project.

2. Build the application using the below command:

Once the build is done, you will find that an ‘instrument’ folder is created under your project and a ‘clover.db’ registry has been created. If you navigate into the classes folder (‘target\classes\hello’) you will also find that there are additional .class files created with _CLR4 appended. These are the instrumented classes.

3.Run the application using the below command from the project directory:

Once the application is started, you can see that there are additional clover .db files created having names such as ‘clover.db.liverec’, ‘clover.db6ivvjj_lkzicfyg’ etc. These files are used to store the details of which lines of code have been traversed in each of the classes when the user is using the application.

4. Now let us generate a Clover report before we use the application and see what the coverage looks like and what lines of code are covered. To generate a clover report we will first need the clover jar file. You can copy the clover jar from the maven repository ({your home directory}\.m2\repository\org\openclover\clover\4.4.1\clover-4.4.1.jar) and place it in your project directory. Once done you can run the below command.

5. You can now open ‘dashboard.html’ under the ‘CloverReports’ folder to view the coverage details. Here you can see that currently there would be only about 30–35% coverage, which would mainly be the code that was used to bring up the application. You can also see that the methods responsible for displaying the home page, login page etc have not been used yet (Highlighted in red).

6. Now navigate to the home page of the application using the URL http://localhost:8080/home. On the home screen click on the ‘here’ link that is displayed. This will take you to the login screen. Once done, generate the report once again using the command in step 4 and view the coverage information in the Clover report.

You can now see that the coverage percentage has increased from 30% to around 65%. Also, the ‘home’ method responsible for displaying the home screen, and the ‘login’ method responsible for displaying the login screen are shown as covered in your Clover report.

And this is how you can ensure that 100% of all your code has been tested, either manually or through automated capabilities, before releasing an application to the production environment without any margin for human error.

Clover also provides advanced capabilities for excluding specific packages, classes and sections of code such as the catch blocks. It also provides capabilities for capturing coverage in a distributed infrastructure as well.

Best Practices for Software Development 2023

Best Practices for Software Development 2023

Introduction:

In today’s rapidly evolving technological landscape, software development continues to play a crucial role in shaping businesses and driving innovation. As technology continues to advance, software development practices evolve to meet the demands of an ever-changing landscape. As we delve into the year 2023, it is essential to identify and adopt the best practices that can help us stay ahead of the curve. This blog aims to highlight the key best practices for software development in 2023 and provide insights into how they can contribute to successful project outcomes.

1. Agile Development:

Agile development methodologies have gained significant popularity in recent years, and they remain one of the best practices for software development in 2023. Emphasising iterative and incremental development, Agile methodologies enable flexibility, adaptability, and rapid feedback loops. Popular frameworks like Scrum and Kanban provide structured approaches to managing projects, allowing teams to deliver high-quality software in shorter cycles.

2. Continuous Integration and Continuous Deployment (CI/CD):

The integration of code changes and their continuous delivery are paramount for maintaining a seamless development workflow. CI/CD practices enable automated build, test, and deployment processes, ensuring that software changes are regularly integrated into a shared repository. By automating these processes, developers can catch and fix issues early, resulting in faster delivery cycles and more reliable software releases.

3. DevOps Culture:

Collaboration between development, operations, and other stakeholders is crucial for successful software development projects. DevOps practices encourage the integration of development and operations teams, fostering a culture of shared responsibility and communication. By breaking down silos and automating infrastructure provisioning, deployment, and monitoring, DevOps practices enable faster time to market, improved quality, and better stability. Below image depicts various tools available today for DevOps practices.

4. Containerization and Microservices:

Containerization, using platforms like Docker and Kubernetes, allows developers to package applications and their dependencies into portable, isolated containers. This approach simplifies deployment, scalability, and maintenance. Microservices architecture complements containerization by breaking down applications into smaller, loosely coupled services, enabling easier development, scaling, and fault isolation.

What is Containerization: Containerization is a software deployment process that bundles an application’s code with all the files and libraries it needs to run on any infrastructure. Traditionally, to run any application on your computer, you had to install the version that matched your machine’s operating system. For example, you needed to install the Windows version of a software package on a Windows machine. However, with containerization, you can create a single software package, or container, that runs on all types of devices and operating systems. 

5. Security-First Approach:

With the growing number of cybersecurity threats, it is vital to incorporate security practices throughout the software development lifecycle. Developers should follow secure coding practices, conduct regular security assessments, and implement necessary measures such as encryption, access controls, and input validation. Staying updated on the latest security vulnerabilities and adopting secure coding frameworks helps protect sensitive data and maintain the trust of users.

6. Test-Driven Development (TDD):

Test-Driven Development is a methodology that emphasises writing tests before developing the corresponding code. By following TDD practices, developers can ensure that the software meets the required functionality and is thoroughly tested. TDD promotes code quality, reduces defects, and improves overall software design.

7. Cloud-Native Development:

Cloud computing has revolutionised the software industry, and in 2023, cloud-native development has gained significant traction. Cloud-native applications are built specifically for the cloud environment, leveraging its scalability, resilience, and agility. Microservices architecture, containerization (e.g., Docker), and orchestration tools (e.g., Kubernetes) are essential components of cloud-native development. Organisations are adopting cloud-native practices to improve scalability, reduce costs, and enhance deployment flexibility.

8. Code Review and Quality Assurance:

Code quality should be a top priority in software development. Implementing regular code reviews ensures that code is clean, maintainable, and adheres to coding standards. Peer code reviews help identify bugs, improve design, and share knowledge among team members. Additionally, automated testing practices, including unit tests, integration tests, and regression tests, contribute to overall quality assurance and reduce the likelihood of introducing new bugs.

9. Documentation and Knowledge Management:

Comprehensive and up-to-date documentation is essential for maintaining and evolving software systems. Developers should invest time in documenting code, APIs, architectural decisions, and system configurations. Adopting knowledge management practices, such as maintaining a centralised knowledge base or utilising wikis, helps preserve institutional knowledge and facilitates future development.

Conclusion:

As software development evolves, embracing the best practices for 2023 is essential to stay competitive and deliver high-quality software products. Agile methodologies, CI/CD practices, collaboration through DevOps, code review, quality assurance, security considerations, and cloud computing with microservices are key areas to focus on. By adopting these best practices, development teams can optimise their processes, reduce time to market, and deliver robust software solutions that meet user expectations in the ever-changing software landscape of 2023.

Satinder Singh

10 Cyber Security Myths to Let Go of in 2023

10 Cyber Security Myths to Let Go Off in 2023

Cybersecurity is a hot topic these days, and for good reason. With the ever-increasing reliance on technology, businesses and individuals are at an increased risk of cyberattacks.

As there are new breaches, hacks, and attacks daily, inadequate cybersecurity preparedness could result in a catastrophic outcome.

So, how do you stay ahead of things?  First – by knowing what’s real and what’s misinformation. Unfortunately, there are a few common misunderstandings about cybersecurity that can lead to people taking unnecessary risks. Let’s clear these myths today.

10 Common Cybersecurity Myths

1. Only big businesses are targeted by hackers. 

This is simply not true. Hackers will target anyone, regardless of their size or industry. In fact, small businesses are often targeted because they are seen as being less secure than larger businesses. While SMBs may not be explicitly targeted, often they are victims of spray-and-pray attacks.

2. My antivirus software is enough to protect me. 

Antivirus software is an important part of cybersecurity, but it is not enough on its own. You also need to practice good security habits, such as using strong passwords, being careful about what links you click on, and keeping your software up to date.

3. I’m not important enough to be hacked. 

This is a dangerous myth. When you sign the Terms and Conditions of Facebook, Twitter, Instagram, Pinterest, Snapchat, TikTok, you’re signing away your right to privacy, which lets the apps build a detailed demographic profile of you.

Everyone is at risk of being hacked, regardless of their importance or social status. Hackers are always looking for new targets, and they don’t care who you are. For mature cybersecurity, the organization should adopt a comprehensive cybersecurity plan that will have everything from the incident response team, plan to insider threat detection and employee training and awareness.

4. I’ll know if I’m being hacked. 

Not necessarily. Hackers are becoming more sophisticated and can hide their tracks. It’s possible that you could be hacked without even realizing it.

5. I can’t do anything to prevent a Cyberattack. 

This is not true. There are several things you can do to protect yourself from cyberattacks, such as practicing good security habits, using a firewall, and backing up your data.

6. Cybersecurity is too expensive. 

Cybersecurity doesn’t have to be too expensive. There are several low-cost security measures you can take to protect yourself. Also, the expense of not enforcing any security extents is higher.

According to IBM’s ‘Cost of a Data Breach Report’ showed that in 2022, the global average cost of a data breach was $4.35M USD (approx. $6.5M AUD).

7. My employees are too smart to be tricked by hackers. 

This is a common misconception. Even the smartest people can be tricked by hackers. That’s why it’s important to train your employees on how to spot and avoid phishing scams and other cyberattacks.

8. Once I’ve been hacked, there’s nothing I can do 

Another myth. There are a several things you can do to recover from a cyberattack, such as changing your passwords, scanning your computer for malware, and reporting the attack to the authorities.

9. Cybersecurity is someone else’s problem

This is a dangerous attitude. Cybersecurity is everyone’s problem. We all need to do our part to protect ourselves and our businesses from cyberattacks. The culture change needed to address this in a real and meaningful way comes from leadership while real cybersecurity preparedness is the responsibility of every employee.

10. I’ll cross that bridge when I come to it

This is a risky approach to cybersecurity. It’s better to be proactive and take steps to protect yourself now, rather than waiting until it’s too late.

By understanding and debunking these common cybersecurity myths, you can help to protect yourself and your business from cyberattacks.

Here are some additional tips for improving your cybersecurity:

  • Use strong passwords and don’t reuse them across different websites and services.
  • Be careful about what links you click on, especially in emails and social media messages.
  • Keep your software up to date, including your operating system, web browser, and antivirus software.
  • Back up your data regularly.
  • Train your employees on how to spot and avoid phishing scams and other cyberattacks.
  • Report any suspicious activity to the authorities.

 

How to increase the velocity of Sprint testing

How to Increase the Velocity of Sprint Testing?


In a fast-delivering agile world, there is a need for increasing the speed of the testing without compromising the quality. Sometimes, MVP (Most Viable Product) releases have a timeline of 45 days. In such a short span, requirements, wireframes, solution design, build, testing, SIT, UAT, security testing, and implementation should happen in time.

Also, as part of cost-cutting well established organisations are reducing testing costs by performing sprint testing in a “one layer above and one layer below” passion.  SIT and UAT are combined as IAT (Integrated Acceptance testing).  So, there is a lot of emphasis on sprint testing in an agile world for delivering a quality product.

When can we start sprint testing??

We can start sprint testing from the very early stage of the project life cycle i.e right from the program increment (PI) planning by considering dependencies/blockers and risks.

Inflight testing

Before the start of a sprint, we may be given a demo of requirements and solution design. We need to perform an impact assessment of new features to the existing code/systems/data and then plan inflight testing accordingly.

Static testing

Performing static testing on the requirements, solution, and wireframes can help to uncover bugs in the early stages of the life cycle.

Test preparation- “Three Amigo session”

Business, Developers, and testers use a different lens while digesting the requirements. If we allow all of them to work independently, they may blame each other for the understanding gaps at the end. “Three amigo session” is one solution for this. It is a meeting set up by a tester where a quick test preparation is done on the fly under the presence of BA, dev, and tester.

Automation

BDD framework like cucumber is the most suitable automation framework for sprint testing. If UI is unstable then we can go one level below and automate the API testing. Based on cost and time parameters, we can do progressive automation and integrate with DevOps pipelines.

Test Execution:

We can start testing whatever that’s readily available. Sometimes, back-end changes get delivered by other scrum teams in future sprints. We can still test UI/API code built by our scrum team by stubbing the back end.  Once, full integration is established we can do early integration testing by covering a few important features and handover the build for further testing like IAT. However, it takes a good coordination effort between testing teams to start IAT testing in parallel with sprint testing.

Sprint Demo:

To uncover UAT bugs upfront, a sprint demo can be given to the business at the end of every sprint.

I wanted to conclude by saying “Sprint tester needs to have craftmanship in every role while building a project.”