SwastikM commited on
Commit
ea312db
1 Parent(s): 203be2b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +47 -1
README.md CHANGED
@@ -76,7 +76,53 @@ code = tokenizer.decode(outputs[0], skip_special_tokens=True)
76
  print(code)
77
  ```
78
 
79
- ### Size Comparison
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
  The table shows comparison VRAM requirements for loading and training
82
  of FP16 Base Model and 4bit GPTQ quantized model with PEFT.
 
76
  print(code)
77
  ```
78
 
79
+ ### A Test Example
80
+ ``````
81
+ User Prompt: Write a Python program to implement K-Means clustering. The program should take two mandatory arguments, k and data, where k is the number of clusters and data is a 2D array containing the data points k = 3
82
+ data = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
83
+
84
+ Generated Output: Write a Python program to implement K-Means clustering. The program should take two mandatory arguments, k and data, where k is the number of clusters and data is a 2D array containing the data points k = 3
85
+ data = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] Ready for action! Let's do this! ```python
86
+ import numpy as np
87
+
88
+ def kmeans(data, k):
89
+ # Initialize the centroids
90
+ centroids = np.random.rand(k, 2)
91
+
92
+ # Initialize the cluster assignments
93
+ cluster_assignments = np.zeros(data.shape[0], dtype=int)
94
+
95
+ # Iterate through the data points
96
+ for i in range(data.shape[0]):
97
+ # Calculate the distance between the current data point and each of the centroids
98
+ distances = np.linalg.norm(data[i] - centroids)
99
+
100
+ # Assign the data point to the closest centroid
101
+ cluster_assignments[i] = np.argmin(distances)
102
+
103
+ return cluster_assignments
104
+ ```
105
+ This program takes two mandatory arguments, `k` and `data`, where `k` is the number of clusters and `data` is a 2D array containing the data points. The program initializes the centroids randomly and then iterates through the data points to calculate the distance between each data point and each of the centroids. The program then assigns each data point to the closest centroid based on the calculated distance. Finally, the program returns the cluster assignments for each data point.
106
+
107
+ Note that this program uses the Euclidean distance to calculate the distance between the data points and the centroids. You can change the distance metric if needed.
108
+
109
+ Also, this program assumes that the data points are 2D. If the data points are 3D or higher, you will need to modify the program accordingly.
110
+
111
+ I hope this helps! Let me know if you have any questions.
112
+
113
+ ```python
114
+ # Example usage
115
+ data = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
116
+ k = 3
117
+ cluster_assignments = kmeans(data, k)
118
+ print(cluster_assignments)
119
+ ```
120
+ This will output the cluster assignments for each data point. The output will be a list of integers, where each integer represents the cluster assignment for that data point. For example, if the data points are
121
+ ---------------------------------------------------------------------
122
+
123
+ ``````
124
+
125
+ ## Size Comparison
126
 
127
  The table shows comparison VRAM requirements for loading and training
128
  of FP16 Base Model and 4bit GPTQ quantized model with PEFT.