Machine Learning with Python

Machine Learning with Python

Introduction

Definition: Process of allowing computers to learn from data without being explicit programming.

It encompasses diverse applications from image recognition to fraud detection.

Application of ML

  1. Predictive Modelling

  2. Natural language processing

  3. Automatic vehicles

  4. Health Care: predictive analysis of diseases, drug discovery, personalized medical care, Imaging interpretation.

Types of Machine Learning

  1. Supervised Learning:

    Requires training data with independent variables and a dependent variable.

    Needs labelled data.

    Includes: Regression model, classification model

    Example: Data that contains animals have labels for example cats, dogs, elephants, etc. The model learns from the labelled data and can later make predictions on unlabelled data.

  2. Unsupervised Learning

    Learns from unlabelled data.

    Requires training data with independent variables only.

    No need for labelled data that can supervise the algorithm when learning from the data

    Includes: Clustering; outlier detection

    Example: The model learns from unlabelled data and can classify similar classes in one category like sorting.

  3. Semi-supervised Learning

    Combines labelled and unlabelled data.

    The algorithm learns from a small amount of labelled data and a large amount of unlabelled

    Example: We have some data where we have animals some are labelled lets say cats and dogs the model on the other hand classifies the rest of the animals.

  4. Reinforcement Learning

    An agent learns to make decisions by receiving feedback from its environment.

Core Concepts

  1. Algorithm: step-by-step instructions for computers to learn and make decisions from data

  2. Datasets: a collection of information used by computers to learn and make predictions

  3. Training: Involves teaching a machine learning algorithm by exposing it to data and adjusting its parameters.

Supervised Learning

Involves training models on labelled datasets where the model learns to map input features to corresponding outputs.

There are 2 main categories:

  1. Classification Supervised: Deals with predicting categorical target variables.

    E.g. classifying emails as spam

    Common algorithms: logistic regression, Support vector machine, Random Forest, Decision Tree, K-nearest neighbour, Naive Bayes

  2. Regression: Involves predicting continuous target variables.

  3. E.g. forecasting sales

common algorithm: linear, Polynomial, Ridge regression,

Machine Learning Lifecycle

  1. Import data: Load the data that consists of the target variable(dependent variable and the features(input)

  2. Clean data: This is the preprocessing phase which involves handling missing data, feature scaling and encoding categorical variables.

  3. split the data into training/test sets: Can either have separate data for testing or split a small percentage of the data provided to be used for testing.

  4. Create a model: Choose an appropriate machine learning algorithm based on the problem at hand and the characteristics of the dataset.

  5. Train the model

  6. Make predictions

  7. Evaluate: evaluate the performance of the trained model using appropriate evaluation metrics. Common metrics include accuracy, precision, recall, F1-score (for classification), and mean squared error, R-squared (for regression).

    Use cross-validation techniques (e.g., k-fold cross-validation) to obtain more reliable estimates of the model's performance and ensure it generalizes well to unseen data.

  8. Continuous improvement

  9. Model Deployment:

    • Once the model has been trained and evaluated satisfactorily, it can be deployed to make predictions on new, unseen data.

Libraries

  1. Numpy

  2. Pandas

  3. Matplotlib

  4. Scikit-Learn

Conclusion

In conclusion, machine learning represents a transformative approach to data analysis and decision-making, with applications spanning across diverse domains such as healthcare, finance, autonomous vehicles, and more.

By allowing computers to learn from data without explicit programming, machine learning enables the extraction of valuable insights, the prediction of future trends, and the automation of complex tasks.

Further Reading

Machine Learning Tutorial Python -1: What is Machine Learning?

What is Machine Learning?