Aychew Chernet
Aychew Chernet
UNIVERSITY
INDIVIDUAL ASSIGNMENT
NAME : AYCHEW
What is Classification ?
Classification is a supervised machine learning method where the model
tries to
predict the correct label of a given input data.
In classification, the model is fully trained using the training data, and
then it is
evaluated on test data before being used to perform prediction on new
unseen
data.
For instance, an algorithm can learn to predict whether a given email is
spam or
ham (no spam), as illustrated below.
1
p=1/(1+−).
Here,z defines the weighted linear combination of the input features and is
calculated
as follows:
z=0+111+22+...+ wn
x
n.
The linear regression algorithm, such as gradient descent, finds the optimal
values
for the weights that maximize the likelihood of the observed data.
2
What is regression?
Regression is a method for understanding the relationship between
independent variables or features and a dependent variable or outcome.
Outcomes can then be predicted once the relationship between
independent and dependent variables has been estimated.
Example of regression
3
# Python code to illustrate
# regression using data set
import matplotlib
matplotlib.use('GTKAgg')
Y = df['price']
X = df['lotsize']
X=X.values.reshape(len(X),1)
Y=Y.values.reshape(len(Y),1)
# Plot outputs
plt.scatter(X_test, Y_test, color='black')
plt.title('Test Data')
plt.xlabel('Size')
plt.ylabel('Price')
plt.xticks(())
plt.yticks(())
# Plot outputs
4
plt.plot(X_test, regr.predict(X_test), color='red',linewidth=3)
plt.show()
What is Clustering?
Introduction to Clustering: It is basically a type of unsupervised learning
method (https://www.geeksforgeeks.org/supervised-unsupervised-
learning/). An unsupervised learning method is a method in which we
draw references from datasets consisting of input data without labeled
responses. Generally, it is used as a process to find meaningful structure,
explanatory underlying processes, generative features, and groupings
inherent in a set of examples.
5
Example of Clustering
#Implementing E step
def assign_clusters(X, clusters):
for idx in range(X.shape[0]):
dist = []
curr_x = X[idx]
for i in range(k):
dis = distance(curr_x,clusters[i]['center'])
dist.append(dis)
curr_cluster = np.argmin(dist)
clusters[curr_cluster]['points'].append(curr_x)
return clusters
6
if points.shape[0] > 0:
new_center = points.mean(axis =0)
clusters[i]['center'] = new_center
clusters[i]['points'] = []
return clusters