1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Elanso [62]
4 years ago
12

1. Implement the k-means clustering algorithm either in Java or Python. • The program should be executable with at least 3 param

eters: the name of the dataset file, k, and the name of the output file. • The output file should contain numerical class labels (formatted as one number per row) for all the records in the test dataset and report the sum squared error (SSE) and silhouette coefficient in the last row. • You only need to handle numerical attributes (categorical attributes are not required).
Engineering
1 answer:
givi [52]4 years ago
4 0

Answer:

The code for this Question in Python is as follows:

matplotlib inline

from copy import deepcopy

import numpy as np

import pandas as pd

from matplotlib import pyplot as plt

plt.rcParams['figure.figsize'] = (16, 9)

plt.style.use('ggplot')

# Importing the dataset

data = pd.read_csv('xclara.csv')

print(data.shape)

data.head()

# Getting the values and plotting it

f1 = data['V1'].values

f2 = data['V2'].values

X = np.array(list(zip(f1, f2)))

plt.scatter(f1, f2, c='black', s=7)

# Number of clusters

k = 3

# X coordinates of random centroids

C_x = np.random.randint(0, np.max(X)-20, size=k)

# Y coordinates of random centroids

C_y = np.random.randint(0, np.max(X)-20, size=k)

C = np.array(list(zip(C_x, C_y)), dtype=np.float32)

print(C)

# To store the value of centroids when it updates

C_old = np.zeros(C.shape)

# Cluster Lables(0, 1, 2)

clusters = np.zeros(len(X))

# Error func. - Distance between new centroids and old centroids

error = dist(C, C_old, None)

# Loop will run till the error becomes zero

while error != 0:

   # Assigning each value to its closest cluster

   for i in range(len(X)):

       distances = dist(X[i], C)

       cluster = np.argmin(distances)

       clusters[i] = cluster

   # Storing the old centroid values

   C_old = deepcopy(C)

   # Finding the new centroids by taking the average value

   for i in range(k):

       points = [X[j] for j in range(len(X)) if clusters[j] == i]

       C[i] = np.mean(points, axis=0)

   error = dist(C, C_old, None)

# Initializing KMeans

kmeans = KMeans(n_clusters=4)

# Fitting with inputs

kmeans = kmeans.fit(X)

# Predicting the clusters

labels = kmeans.predict(X)

# Getting the cluster centers

C = kmeans.cluster_centers_

fig = plt.figure()

ax = Axes3D(fig)

ax.scatter(X[:, 0], X[:, 1], X[:, 2], c=y)

ax.scatter(C[:, 0], C[:, 1], C[:, 2], marker='*', c='#050505', s=1000)

You might be interested in
The denominator of a fraction is 4 more than the numenator. If 4 is added to the numenator and 7 is added to the denominator, th
kati45 [8]

Answer:

\frac{3}{7}

Explanation:

Lets take the numerator of the fraction to be = x

So the denominator of the fraction is 4 more than the numerator = x+4

The fraction is ;\frac{x}{4+x}

Now add 4 to the numerator and add 7 to the denominator as;

\frac{x+4}{4+x+7} =\frac{x+4}{x+11}

This new fraction is equal to 1 half =1/2

write the equation as;

\frac{x+4}{x+11} =\frac{1}{2}

perform cross-product

2(x+4 )=1( x+11 )

2x+8 = x + 11

2x-x = 11-8

x=3

The original fraction is;  

\frac{x}{4+x} =\frac{3}{3+4} =\frac{3}{7}

3 0
3 years ago
3.8 LAB - Select lesson schedule with multiple joins
dem82 [27]

Answer:

The database has three tables for tracking horse-riding lessons: Horse with columns: ID - primary key; RegisteredName; Breed; Height; BirthDate.

Explanation:

4 0
2 years ago
Pointssss 100 and brainliest :)
Delvig [45]

Answer:

thank you for the free point have a great rest of your day

7 0
3 years ago
A fatigue test was conducted in which the mean stress was 90 MPa (13050 psi), and the stress amplitude was 190 MPa (27560 psi).
Gwar [14]

Answer:

a) 280MPa

b) -100MPa

c) -0.35

d) 380 MPa

Explanation:

GIVEN DATA:

mean stress \sigma_m = 90MPa

stress amplitude \sigma_a = 190MPa

a) \sigma_m =\frac{\sigma_max+\sigma_min}{2}

    90 =\frac{\sigma_{max}+\sigma_{min}}{2} --------------1

\sigma_a =\frac{\sigma_{max}-\sigma_{min}}{2}

   190 = \frac{\sigma_{max}-\sigma_{min}}{2} -----------2

solving 1 and 2 equation we get

\sigma_{max} = 280MPa

b) \sigma_{min} = - 100MPa

c)

stress ratio=\frac{\sigma_{min}}{\sigma_{max}}

=\frac{-100}{280} = -0.35

d)magnitude of stress range

                      =(\sigma_{max} -\sigma_{min})

                       = 280 -(-100) = 380 MPa

3 0
3 years ago
The insulation resistance of a motor operated by an electronic drive is to be tested using a megger. What precaution should you
EleoNora [17]
Use protective gear. Use insulated tools, Wear flame resistant clothing, safety glasses, and insulation gloves, Remove watches or other jewelry, Stand on an insulation mat. 03. Never connect the insulation tester to energized conductors or energized equipment and always follow the manufacturer's recommendations. When installing new electrical machinery or equipment, testing insulation resistance is important for two reasons. First, it ensures that the insulation is in adequate condition to begin operation. ... The test is accomplished by applying DC voltage through the de-energized circuit using an insulation tester. Insulation resistance should be approximately one megohm for each 1,000 volts of operating voltage, with a minimum value of one megohm. For example, a motor rated at 2,400 volts should have a minimum insulation resistance of 2.4 megohms.
4 0
3 years ago
Other questions:
  • The air contained in a room loses heat to the surroundings at a rate of 50 kJ/min while work is supplied to the room by computer
    11·2 answers
  • If a pendulum takes 2 sec to swing in each direction, find the period and the frequency of the swing
    15·1 answer
  • El protozoos es del reino protista?
    14·2 answers
  • A 100-ampere resistor bank is connected to a controller with conductor insulation rated 75°C. The resistors are not used in conj
    8·1 answer
  • What form of joining uses heat to create coalescence of the materials?
    7·1 answer
  • <img src="https://tex.z-dn.net/?f=%5Cint%5Climits%5Ea_b%20%7B7x%7D%20%5C%2C%20dx" id="TexFormula1" title="\int\limits^a_b {7x} \
    8·1 answer
  • What is the best way to collaborate with your team when publishing Instagram Stories from Hootsuite?
    14·1 answer
  • What's the best way to find the load capacity of a crane?
    6·1 answer
  • A composite plane wall consists of a 5-in.-thick layer of insulation (ks = 0.029 Btu/h*ft*°R) and a 0.75-in.-thick layer of sidi
    11·1 answer
  • The ______ number of a flow is defined as the ratio of the speed of flow to the speed of sound in the flowing fluid.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!