Problem Statement: You work in XYZ Company as a Python Developer. The company officials want you to write code for an Agglomerative Clustering Problem. Tasks To Be Performed: 1. Load iris data from load_iris function from sklearn.datasets package 2. From the dataset extract the data property 3. Train an Agglomerative Clustering model based on the data 4. Plot dendrogram to visualize the clustering linkage
Added by Jennifer O.
Close
Step 1
pyplot as plt from sklearn.datasets import load_iris from sklearn.cluster import AgglomerativeClustering from scipy.cluster.hierarchy import dendrogram, linkage ``` Show more…
Show all steps
Your feedback will help us improve your experience
Sri K and 66 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
6. Linear Regression with L2 (Ridge) Regularization def ridge_regression(X, Y, iterations=1000, learning_rate=.01, L2_penalty=1): no_of_training_examples, no_of_features = X.shape np.zeros(no_of_features) for _ in range(iterations): b, W = update_weights(X, Y, no_of_training_examples, learning_rate, L2_penalty) 7. Split the dataset into training and test sets def train_test_split(dataset, split): ### YOUR CODE HERE ### return X_train, Y_train, X_test, Y_test 8. Perform regression algorithm on dataset def evaluate_ridge_regression(dataset, split): X_train, Y_train, X_test, Y_test = functions.train_test_split(dataset, split) # Train the model b, W = functions.ridge_regression(X_train, Y_train, iterations=10000, L2_penalty=0.01) # Make a prediction with the model yhat = functions.predict(X_test, b, W) print("Predicted values:", np.round(yhat[:3], 2)) print("Real values:", Y_test[3]) print("Trained W:", round(W[0], 2)) print("Trained b:", round(b, 2)) visualise(X_test, Y_test, yhat)
Sri K.
Write a class named Employee that holds the following data about an employee in attributes: name, ID number, department, and job title. Once you have written the class, write a Python program that creates 3 Employee objects to hold the following data: Name: Susan Meyers, ID number: 47899, Department: Accounting, Job Title: Vice President Name: Mark Jones, ID Number: 39119, Department: IT, Job Title: Programmer Name: Jon Rogers, ID Number: 81774, Department: Manufacturing, Job Title: Engineer The program should store this data in the 3 objects and then display the data for each employee on the screen.
Akash M.
A company believes that their new training program increases employee productivity. They collect data from two groups: before training and after training. Perform a two-sample T-test to determine if there is a significant difference in productivity. Begin your script with: import numpy as np from scipy import stats # Sample data (productivity scores) before_training = np.array([85, 82, 88, 78, 90, 80, 87, 83, 79, 82]) after_training = np.array([92, 88, 95, 85, 96, 87, 91, 86, 89, 90])
James K.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD