Google Lighthouse – Measure Web page performance

Common Accessibility issues

1. Missing or Inappropriate alt Text

Issue: Images without descriptive alt text can create problems for users relying on screen readers.

Solution: Add meaningful alt text to images. Use empty alt attributes (alt=””) for decorative images that do not provide important information.

2. Poor Color Contrast

Issue: Low contrast between text and background can make content difficult to read, especially for visually impaired users.

Solution: Ensure a minimum contrast ratio of 4.5:1 for normal text and 3:1 for large text (WCAG 2.1 standards). Use contrast-checking tools.

3. Missing or Incorrect Keyboard Navigation

Issue: Users who rely on keyboards can’t navigate a website if interactive elements (links, buttons, forms) are not accessible via keyboard.

Solution: Ensure that all interactive elements are keyboard-navigable using Tab, Enter, Space, and arrow keys.

4. Lack of Focus Indicators

Issue: Without visible focus indicators, keyboard users may not know where they are on the page.

Solution: Provide clear focus styles (e.g., borders or background color changes) for interactive elements when they are in focus.

5. Non-semantic HTML (Improper Use of ARIA)

Issue: Using non-semantic HTML elements (like <div> and <span>) for interactive elements without roles or labels can confuse screen readers.

Solution: Use semantic HTML elements (like <button>, <nav>, <header>) where possible. If using ARIA roles, use them appropriately to ensure compatibility.

6. Missing Form Labels

Issue: Forms without associated labels make it difficult for screen readers to convey what information is required.

Solution: Use <label> elements for all form fields, and associate them with inputs using the for attribute. For complex forms, use ARIA attributes like aria-label or aria-labelledby.

7. Empty Links or Buttons

Issue: Links or buttons without visible text or proper labels can confuse screen readers.

Solution: Ensure that every interactive element has a meaningful label or aria-label.

8. Improper Heading Structure

Issue: Skipping heading levels or using headings out of order can make it difficult for screen readers to navigate content.

Solution: Use headings (<h1>, <h2>, <h3>, etc.) in a logical order, and avoid skipping levels (e.g., jumping from <h1> to <h3>).

9. Missing or Incorrect aria Attributes

Issue: Using ARIA attributes incorrectly can cause confusion for screen reader users.

Solution: Use ARIA attributes (like aria-labelledby, aria-hidden, aria-live) as intended, and avoid overuse if native HTML elements can achieve the same purpose.

10. Dynamic Content Without Alerts

Issue: Screen readers may not be aware of dynamic changes (e.g., modal pop-ups, form validation errors, AJAX updates).

Solution: Use ARIA live regions (aria-live, role=”alert”) to inform screen readers of dynamic changes.

11. Non-descriptive Link Text

Issue: Links with generic text like “Click here” or “Read more” don’t provide context for screen readers.

Solution: Use descriptive link text that clearly indicates the destination or action, like “Read more about accessibility guidelines.”

12. No Skip Navigation Link

Issue: Users who rely on keyboards may have to tab through many links before reaching the main content.

Solution: Provide a “Skip to main content” link that allows users to bypass repetitive navigation.

13. Video/Audio Without Captions or Transcripts

Issue: Videos and audio content without captions or transcripts are inaccessible to users with hearing impairments.

Solution: Provide captions for videos and transcripts for audio content. Use <track> elements for video subtitles or closed captions.

14. Automatic Media Playback

Issue: Automatically playing audio or video can be disruptive, especially for users with cognitive impairments or screen reader users.

Solution: Disable auto-play by default, or provide a clear option to stop/pause media. Use controls for <video> elements.

15. Improper Use of Tables

Issue: Using tables for layout purposes can be confusing for screen readers, and improperly structured data tables can make information difficult to navigate.

Solution: Use tables only for tabular data and ensure they have proper headers (<th> with scope attribute) and captions. Avoid using tables for layout.

16. Flashing Content

Issue: Flashing or rapidly changing content can cause seizures in users with photosensitive epilepsy.

Solution: Avoid flashing content or ensure it follows the WCAG guidelines (flashing should not exceed 3 times per second).

17. Content That Requires a Mouse

Issue: Interactive elements that rely on mouse actions, like hover menus, may not be accessible to keyboard-only users.

Solution: Ensure that all interactions can be performed using keyboard controls.

18. PDF Accessibility Issues

Issue: PDFs without proper tagging, structure, or alt text for images can be difficult for screen readers.

Solution: Use tools like Adobe Acrobat Pro to check PDF accessibility, add tags, and provide text descriptions for images.

19. Non-responsive Design

Issue: Fixed layouts that don’t adapt to different screen sizes can be problematic for mobile users or those with zoom requirements.

Solution: Use responsive design techniques like CSS Flexbox/Grid and media queries to ensure content adapts to different screen sizes.

20. Inconsistent Focus Order

Issue: An illogical or unpredictable focus order can disorient users relying on keyboard navigation.

Solution: Ensure a logical and predictable tab order, and use the tabindex attribute when necessary to control focus flow.

Google Lighthouse to the rescue!!!!!

Google Lighthouse evaluates a webpage’s performance based on five main categories: Performance, Accessibility, Best Practices, SEO, and Progressive Web App (PWA). Below are the key parameters for each category:

1. Performance

First Contentful Paint (FCP): Measures how long it takes for the first piece of content (text, image, etc.) to be visible.

Largest Contentful Paint (LCP): The time it takes for the largest piece of content to load, crucial for user-perceived load speed.

Speed Index: Shows how quickly the content is visually displayed during page load.

Time to Interactive (TTI): Measures how long the page takes to fully interact.

Total Blocking Time (TBT): Indicates the time between FCP and TTI where the main thread is blocked, preventing interaction.

Cumulative Layout Shift (CLS): This measures the page’s visual stability and indicates any unexpected layout shifts.

2. Accessibility

Color Contrast: Checks if the text has sufficient contrast for readability.

Alt Text: Ensures images have descriptive alt attributes for accessibility.

ARIA Attributes: Verifies if ARIA attributes are correct and used appropriately for assistive technologies.

Form Labels: Checks if form fields have appropriate labels for accessibility.

Tab Order: Evaluate the logical navigation order for keyboard users.

3. Best Practices

HTTPS Usage: Verifies if all resources are loaded securely over HTTPS.

JavaScript Errors: Checks for any errors in JavaScript execution.

Image Aspect Ratio: Ensures images have correct aspect ratios.

Deprecation Usage: Flags deprecated APIs or web features.

4. SEO

Meta Descriptions: Ensures every page has a unique and adequate meta description.

Links Accessibility: Checks for the presence of link text that’s descriptive.

Crawlable Pages: Ensures all pages are easily crawlable by search engines.

Document Title: Verifies the presence of a descriptive and unique title tag.

HTTP Status Code: Ensures that HTTP status codes are appropriate for the content (e.g., 200 for successful load).

5. Progressive Web App (PWA)

Service Workers: Ensures service workers are registered for offline functionality.

Installable: Checks if the app is installable as a PWA (manifest presence and correct settings).

Fast Load: Evaluate how fast the app loads under a 3G network.

Offline Access: Ensures the app works offline or in low connectivity situations.

Responsive Design: Confirms that the app adjusts to various screen sizes and orientations.

Additional Settings for Custom Audits

Simulated vs. Real-World Throttling: You can choose to simulate slow networks or use real-world data.

Device Emulation: Mobile or desktop simulation options.

Audit Options: Customize the audits (e.g., exclude certain metrics if needed).

These parameters allow for comprehensive analysis and are typically configurable based on your specific needs in Lighthouse.

AI Model – Bias, Variance, Underfitting, Overfitting

Reducing Bias (to prevent underfitting)

Increase Model Complexity:

• Use more complex models, such as deep neural networks, or add more layers and neurons to existing models.

• Use models that capture non-linear relationships (e.g., decision trees, random forests, or support vector machines with non-linear kernels).

Feature Engineering:

• Add more relevant features that may capture the underlying patterns in the data.

• Transform features to better represent the data (e.g., polynomial features, interaction terms).

Increase Training Time:

• Train the model for more epochs, especially for deep learning models, to allow them to learn more complex patterns.

Reducing Variance (to prevent overfitting)

Simplify the Model:

• Use a simpler model with fewer parameters to avoid overfitting the training data.

• Reduce the number of layers or units in a neural network, or prune a decision tree.

Increase Training Data:

• Collect more data to give the model more examples, helping it generalize better to unseen data.

Regularization Techniques:

• Augment the existing dataset with transformations (for images, techniques like rotation, flipping, and cropping).
• Split into training and test data sets multiple times

• Use L1/L2 Regularization: Adds a penalty term to the loss function, discouraging the model from fitting noise.

• Use Dropout (for neural networks): Randomly drop neurons during training to prevent the model from becoming too dependent on specific pathways.

• Use Early Stopping: Stop training when performance on a validation set starts to degrade, indicating overfitting.

Confusion Matrix


A confusion matrix is a table used to evaluate the performance of a classification model by showing the true and predicted classifications for a set of test data. It helps in visualizing and analyzing how well the model is performing, especially for multi-class classification problems. The confusion matrix provides a detailed breakdown of the correct and incorrect predictions, making it easier to understand the types of errors the model is making.

  1. Accuracy: The proportion of correct predictions (both true positives and true negatives) out of all predictions.

Accuracy = (TP + TN) / (TP + TN + FP + FN)

2. Precision: The proportion of true positive predictions out of all positive predictions made by the model.

Precision (Positive Predictive Value) = TP / TP + FP

3. Recall (Sensitivity, True Positive Rate): The proportion of actual positives correctly identified by the model. Recall represents from all the positive classes, how many we predicted correctly.

Recall should be as high as possible.

Recall = (TP) / (TP + FN)


The term “recall” reflects the model’s ability to “recall” or recognize as many true positive instances as possible from the actual positive cases in the dataset. It focuses on minimizing the number of false negatives, ensuring that the model identifies the majority of relevant instances.

4. F1 Score: The harmonic mean of precision and recall, providing a single metric that balances both.

F1 Score = 2 * (Precision * Recall) / (Precision + Recall)

5. Specificity (True Negative Rate): The proportion of actual negatives correctly identified by the model.

Specificity = TN / (TN + FP)


6. ROC-AUC (Receiver Operating Characteristic – Area Under the Curve)
The ROC curve plots the true positive rate (recall) against the false positive rate at various threshold settings. The AUC (Area Under the Curve) represents the likelihood that the model will rank a randomly chosen positive instance higher than a randomly chosen negative one.

https://developers.google.com/machine-learning/crash-course/classification/roc-and-auc

7. PR-AUC (Precision-Recall Area Under the Curve); The Precision-Recall curve plots precision against recall at various threshold settings. The AUC represents the balance between precision and recall across different thresholds.

8. Logarithmic Loss (Log Loss): Log Loss measures the performance of a classification model where the output is a probability value between 0 and 1. It penalizes incorrect classifications with more confidence more than those with less confidence.

9. Mean Absolute Error (MAE): MAE measures the average absolute difference between the predicted values and the actual values. It provides a straightforward interpretation of the error magnitude.

10. Mean Squared Error (MSE): MSE measures the average squared difference between the predicted values and the actual values. It penalizes larger errors more heavily than MAE, due to the squaring of the differences.

MetricEquationInterpretation
Mean Absolute Error (MAE)MAE = (1/n) * Σ | yᵢ – ŷᵢ |Measures the average magnitude of errors between actual and predicted values.
Mean Squared Error (MSE)MSE = (1/n) * Σ (yᵢ – ŷᵢ)²Penalizes larger errors more heavily by squaring them, emphasizing the impact of large deviations.
Mean Absolute Percentage Error (MAPE)MAPE = (100/n) * Σ | (yᵢ – ŷᵢ) / yᵢ |Expresses the prediction error as a percentage of the actual values, useful for understanding relative error.
Root Mean Squared Error (RMSE)RMSE = √((1/n) * Σ (yᵢ – ŷᵢ)²)Similar to MSE but in the same units as the target variable, providing a direct interpretation of the error magnitude.
R² (Coefficient of Determination)R² = 1 – (Σ (yᵢ – ŷᵢ)²) / (Σ (yᵢ – ȳ)²)Measures the proportion of variance in the dependent variable that is predictable from the independent variables.

How to choose the right metric

MetricWhen to UseWhen to Avoid
Accuracy– Classes are balanced
– Equal cost for false positives (FP) and false negatives (FN)
– Class imbalance
– Different costs for FP and FN
Precision– Minimizing false positives is crucial
– High cost of false positives
– Minimizing false negatives is more important
– When recall is more critical
Recall– Minimizing false negatives is crucial
– High cost of false negatives
– Minimizing false positives is more important
– When precision is more critical
F1 Score– Balance between precision and recall
– Class imbalance
– When one metric (precision or recall) is more critical
– High cost asymmetry between FP and FN
Specificity– Minimize false positives
– Negative class is more important
– When false negatives are more critical
– Positive class is more important
ROC-AUC– Evaluate model’s discrimination ability
– Class imbalance
– Focus on a specific threshold
– Misleading in highly imbalanced datasets
PR-AUC– Class imbalance with positive class of interest
– Focus on correctly identifying positive class
– Both classes are equally important
– When ROC-AUC is sufficient
Logarithmic Loss (Log Loss)– Evaluating probability estimates
– Need to know confidence in predictions
– Only need classification labels
– Interpretability is preferred
Mean Absolute Error (MAE)– Regression problems
– Understanding average error
– Penalizing larger errors
– Classification problems
Mean Squared Error (MSE)– Regression problems
– Error sensitivity
– Evaluate the model’s discrimination ability
– Class imbalance

AWS SageMaker

AWS SageMaker is a fully managed service that allows data scientists and developers to build, train, and deploy machine learning models at scale. It simplifies the process of developing and deploying machine learning models by offering tools and capabilities to perform each step of the machine learning workflow, from preparing data to monitoring deployed models.

Key Features of AWS SageMaker:

1. Data Preparation and Labeling:

SageMaker Data Wrangler: Helps prepare and clean data without writing much code.

SageMaker Ground Truth: Enables automated data labeling for training datasets, using human labelers and machine learning models to improve labeling efficiency.

2. Model Building:

SageMaker Studio: An integrated development environment (IDE) that offers tools to build, train, and deploy machine learning models. It’s a web-based interface that supports Jupyter notebooks and various integrations.

Built-in Algorithms: Offers many pre-built algorithms optimized for performance and scalability, such as XGBoost, linear regression, k-means, and more.

Custom Algorithms: Users can also bring their own custom algorithms written in popular frameworks like TensorFlow, PyTorch, Scikit-learn, etc.

Amazon SageMaker Autopilot: Automatically trains and tunes the best machine learning models without requiring the user to know much about machine learning (AutoML).

3. Model Training:

Distributed Training: SageMaker allows training on large datasets by automatically distributing the training job across multiple instances.

Spot Training: Reduces cost by using Amazon EC2 Spot Instances for model training.

Hyperparameter Optimization (HPO): Automates the process of tuning a model’s hyperparameters to improve accuracy.

4. Model Deployment and Hosting:

Real-time Inference: Deploy trained models as endpoints for real-time predictions.

Batch Transform: For batch inference, where the predictions are done in bulk for datasets that don’t require real-time predictions.

SageMaker Model Monitor: Provides continuous monitoring of deployed models to ensure their quality over time.

5. Model Explainability and Debugging:

SageMaker Clarify: Provides insights into model fairness and explainability by analyzing bias in data and providing explanations for model predictions.

SageMaker Debugger: Automatically captures and analyzes model training metrics in real time to help debug and improve models.

6. MLOps and Pipelines:

SageMaker Pipelines: Supports MLOps by helping build, manage, and automate end-to-end machine learning workflows, making it easier to retrain and deploy models in production.

SageMaker Projects: Helps set up CI/CD pipelines for model deployment, making it easier to integrate machine learning models into existing DevOps workflows.

How to Use SageMaker:

1. Preparing Data: Use SageMaker Data Wrangler or Ground Truth to clean, prepare, and label the data.

2. Building Models: Use SageMaker Studio to write code, explore data, and build models using pre-built or custom algorithms.

3. Training Models: Train models at scale, optimize hyperparameters, and utilize distributed computing or EC2 Spot Instances for cost efficiency.

4. Deploying Models: Deploy models for real-time or batch inference, and monitor performance using SageMaker Model Monitor.

5. Managing Workflows: Use SageMaker Pipelines for continuous integration and deployment (CI/CD) of models into production.

 

AWS SageMaker Algorithms:

1. Supervised Learning Algorithms:

Linear Learner: For binary and multiclass classification or regression problems. It uses stochastic gradient descent (SGD) for fast model training.

XGBoost: An optimized distributed gradient boosting library designed for speed and performance. Great for classification and regression tasks.

K-Nearest Neighbors (k-NN): A simple, non-parametric algorithm used for classification and regression. It predicts the label of an unseen data point by calculating the distance between the data points.

Factorization Machines: Suitable for recommendation systems and tasks involving sparse datasets like click prediction.

Image Classification: A pre-built algorithm based on ResNet that is used for image classification tasks.

Object Detection: Helps detect objects in images, based on the Single Shot Multibox Detector (SSD) algorithm.

Semantic Segmentation: A deep learning algorithm that helps segment parts of an image (e.g., identifying specific objects in an image).

2. Unsupervised Learning Algorithms:

K-Means: A clustering algorithm that partitions data into a set number of clusters, widely used in exploratory data analysis.

Principal Component Analysis (PCA): A dimensionality reduction algorithm, used to reduce the number of features while retaining variance in the data.

Anomaly Detection with Random Cut Forest (RCF): Used to detect anomalous data points in a dataset, commonly used for fraud detection or anomaly detection in time-series data.

3. Time Series Forecasting:

DeepAR: A forecasting algorithm that uses recurrent neural networks (RNNs) to predict future values in a time series, ideal for forecasting demand, financial markets, or energy consumption.

4. Natural Language Processing (NLP) Algorithms:

BlazingText: A highly optimized implementation of Word2Vec for text classification or word embeddings.

Seq2Seq: Sequence-to-sequence models used for machine translation, text summarization, and other NLP tasks.

Latent Dirichlet Allocation (LDA): A topic modeling algorithm that helps identify themes or topics in large collections of text.

5. Reinforcement Learning (RL):

Reinforcement Learning with Ray: A toolkit that helps set up reinforcement learning tasks, integrating easily with Ray RLlib for distributed reinforcement learning.

Coach: SageMaker RL allows users to work with Coach, a toolkit for distributed RL training, used for applications like robotic control, game AI, and more.

6. Generative AI and Variational Autoencoders (VAE):

VAE: Used to generate new data similar to training data, for applications like anomaly detection, data synthesis, or generative modeling.

7. Other Algorithms:

IP Insights: Used for identifying suspicious or anomalous IP addresses based on previous behavior, commonly used in cybersecurity.

Neural Topic Model (NTM): Another approach for topic modeling, using deep learning to model topics in textual data.

What is SageMaker Automatic Model Tuning?

Automatic Model Tuning in SageMaker, also called Hyperparameter Optimization (HPO), is a managed service that automates the process of finding the optimal hyperparameters for your machine learning models. Hyperparameters are settings like learning rate, batch size, or number of layers in a neural network, which need to be adjusted for a model to perform well.

Instead of manually tuning these hyperparameters (which can be very time-consuming), SageMaker automates the search by training multiple models with different hyperparameter combinations and selecting the one that performs best based on a chosen metric.

How SageMaker Automatic Model Tuning Works:

1. Define the Hyperparameters: You define a set of hyperparameters and their ranges or values to explore during the tuning process. For example, you might define that the learning rate can be between 0.001 and 0.1.

2. Objective Metric: You specify an objective metric, such as validation accuracy, log loss, F1 score, RMSE. You can use built-in metrics (like Validation:Accuracy) or define your own custom metrics.

3. Search/Tuning Strategy:

• SageMaker uses techniques like Bayesian Optimization to intelligently search the hyperparameter space rather than trying every possible combination (which would be inefficient).

4. Training Jobs: SageMaker runs multiple training jobs, each with different hyperparameter combinations, in parallel. These jobs evaluate the model’s performance on the chosen objective metric.

5. Training Ranges:

• For continuous hyperparameters (like learning rate), you define a range (e.g., from 0.001 to 0.1).

• For categorical hyperparameters (like optimizer type), you define specific values to explore (e.g., [“Adam”, “SGD”, “RMSprop”]).

6. Optimal Hyperparameters: After all the jobs are complete, SageMaker identifies the hyperparameter combination that produced the best-performing model.

7. Stopping Conditions:

• You can set a limit for how many training jobs to run and how long each job can last. This prevents overly long or expensive training sessions.

AWS AI Services

This table comprehensively overviews various AWS AI/ML services, their purposes, features, use cases, and advanced capabilities.

AWS ServicePurposeKey FeaturesCommon Use CasesAdvanced Features
Amazon ComprehendNatural Language Processing (NLP) serviceSentiment analysis, entity recognition, key phrases, language detection, PII detection, topic modelingAnalyzing customer feedback, document classification, and healthcare data insightsCustom entity recognition, custom classification, topic modeling
Amazon TranslateMachine translation of text between languagesNeural machine translation, real-time translation, batch translation, custom terminologyGlobal websites, translating user-generated content, multilingual supportCustom terminology, batch translation, language auto-detection
Amazon TextractExtracts structured data from documentsText extraction, form data extraction, table data extraction, handwriting recognitionAutomating data entry, form processing, and extracting info from financial documentsStructured data extraction, table detection, multi-page document handling
Amazon RekognitionImage and video analysisObject and activity detection, facial recognition, content moderation, custom labelsAutomated content moderation, facial analysis for security, object detectionCustom labels, content moderation, text detection in images, face comparison
Amazon KendraIntelligent search across enterprise dataSearch documents across data sources, natural language search queries, relevance tuningEnterprise document search, knowledge management, internal search toolsSynonym search, relevance tuning, connectors to multiple data sources
Amazon LexBuild conversational interfaces (chatbots)Natural language understanding (NLU), automatic speech recognition (ASR), context managementCustomer service chatbots, virtual assistants, voice-activated applicationsMulti-turn conversations, context management, integrated with Polly
Amazon PollyConverts text into lifelike speechNeural Text-to-Speech (NTTS), multiple voices and languages, SSML support, speech marksVoice applications, audiobooks, newsreaders, virtual assistantsNTTS, newscaster and conversational styles, whispering support, custom lexicons
Amazon TranscribeConverts speech to textReal-time transcription, speaker identification, custom vocabulary, punctuationTranscribing calls, meeting recordings, subtitle generationReal-time transcription, custom vocabulary, speaker identification, channel identification
Amazon PersonalizeReal-time personalized recommendations using MLUser data recommendations, personalized ranking, real-time personalizationE-commerce product recommendations, content personalization, user engagementCustom models, real-time predictions, event tracking, batch inference
AWS DeepRacerAutonomous racing car powered by reinforcement learning3D racing simulator, reinforcement learning models, training in virtual environmentsLearning reinforcement learning, developing self-driving models, competitionsReinforcement learning model training, 3D simulator, evaluation in physical car
Amazon ForecastTime-series forecasting service using machine learningPredict future values from historical data, integrates with Amazon SageMaker, accuracy tuningDemand forecasting, financial planning, inventory managementAccuracy tuning, probabilistic forecasting, quantile forecasting
Amazon Mechanical TurkCrowdsourcing for human intelligence tasksAssign tasks to human workers, gather large-scale labeled data, and affordable data annotationImage labeling, data entry, survey collection, sentiment analysisQuality control, automated workflows, large-scale human workforce access
Amazon Transcribe MedicalConverts medical speech to textMedical speech recognition, HIPAA eligibility, real-time transcription, speaker identificationTranscribing doctor-patient conversations, medical dictationReal-time transcription, medical terminology support, speaker identification
Amazon Comprehend MedicalExtracts medical information from unstructured textIdentifies medical entities (medications, conditions, treatments), ICD-10 codes, relationship detectionExtracting medical records, clinical data analysis, improving healthcare workflowsMedical entity extraction, relationship detection, protected health information (PHI) detection
Amazon Augmented AI (A2I)Adds human review to AI workflowsHuman review workflows, integrated with Amazon Rekognition, Textract, and ComprehendContent moderation, complex document review, healthcare record validationCustom human review workflows, integration with Rekognition, Textract, and Comprehend