Skip to main content

The Transformative Power of Artificial Intelligence: Shaping the Future

  The Transformative Power of Artificial Intelligence: Shaping the Future In the realm of technological advancements, few innovations have captured the world's imagination as much as Artificial Intelligence (AI). From science fiction to reality, AI has become a powerful force driving transformative changes across various industries and sectors. Its significance cannot be overstated, as it has the potential to reshape the way we live, work, and interact with our surroundings. In this blog, we delve into the importance of AI and explore the profound impact it has on our society. 1. Enhancing Efficiency and Productivity: One of the most apparent benefits of AI is its ability to boost efficiency and productivity across industries. By automating repetitive tasks, AI liberates human resources to focus on more complex and creative endeavors. Businesses can streamline processes, optimize resource allocation, and make data-driven decisions faster, resulting in cost savings and increased com...

What is Calculus in Machine Learning | April 2021

I. Introduction

II. Optimization Using the Gradient Descent Algorithm

II.1 Derivatives and Gradients

Minimum of a simple function using gradient descent algorithm. Image by Benjamin O. Tayo

II.2 Case Study: Building a Simple Regression Estimator

II.3 Gradient Descent Algorithm

II.4 Python Implementation

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
class GradientDescent(object):
"""Gradient descent optimizer.
Parameters
------------
eta : float
Learning rate (between 0.0 and 1.0)
n_iter : int
Passes over the training dataset.

Attributes
-----------
w_ : 1d-array
Weights after fitting.
errors_ : list
Error in every epoch.
""" def __init__(self, eta=0.01, n_iter=10):
self.eta = eta
self.n_iter = n_iter

def fit(self, X, y):
"""Fit the data.

Parameters
----------
X : {array-like}, shape = [n_points]
Independent variable or predictor.
y : array-like, shape = [n_points]
Outcome of prediction.
Returns
-------
self : object
"""
self.w_ = np.zeros(2)
self.errors_ = []

for i in range(self.n_iter):
errors = 0
for j in range(X.shape[0]):
self.w_[1:] += self.eta*X[j]*(y[j] - self.w_[0] - self.w_[1]*X[j])
self.w_[0] += self.eta*(y[j] - self.w_[0] - self.w_[1]*X[j])
errors += 0.5*(y[j] - self.w_[0] - self.w_[1]*X[j])**2
self.errors_.append(errors)
return self
def predict(self, X):
"""Return predicted y values"""
return self.w_[0] + self.w_[1]*X

II.5 Application of basic regression model

np.random.seed(1)
X=np.linspace(0,1,10)
y = 2*X + 1
y = y + np.random.normal(0,0.05,X.shape[0])
gda = GradientDescent(eta=0.1, n_iter=100)
gda.fit(X,y)
y_hat=gda.predict(X)
plt.figure()
plt.scatter(X,y, marker='x',c='r',alpha=0.5,label='data')
plt.plot(X,y_hat, marker='s',c='b',alpha=0.5,label='fit')
plt.xlabel('x')
plt.ylabel('y')
plt.legend()
Image by Benjamin O. Tayo
R_sq = 1-((y_hat - y)**2).sum()/((y-np.mean(y))**2).sum()
R_sq
0.991281901588877

III. Summary and Conclusion


Comments

Ads

Popular posts from this blog

Top 10 Data Visualization Tools for Every Data Scientist | April 2021

  At present, the data scientist is one of the most sought after professions. That’s one of the main reasons why we decided to cover the latest data visualization tools that every data scientist can use to make their work more effective. By Andrea Laura, Freelance Writer   One of the most well-settled fields of study and practice in the IT industry today, Data Science has been in the limelight for nearly a decade now. Yes, that's right! It has proven to be a boon in multiple industry verticals. From top of the line methodologies to analyzation of the market, this technology primarily includes obtaining valuable insights from data. This obtained data is then processed where data analysts further analyze the information to find a pattern and then predict the user behavior based on the analyzed information. This is the part where data visualization tools come into play. In this article, we will be discussing some of the best data visualization tools that data scientists need to t...