Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 581f669

Browse filesBrowse files
committed
added stock prediction README & fixed kmeans tutorial code
1 parent 1f46e8e commit 581f669
Copy full SHA for 581f669

File tree

Expand file treeCollapse file tree

2 files changed

+10
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-3
lines changed
Open diff view settings
Collapse file

‎machine-learning/kmeans-image-segmentation/kmeans_segmentation.py‎

Copy file name to clipboardExpand all lines: machine-learning/kmeans-image-segmentation/kmeans_segmentation.py
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@
2828
# convert back to 8 bit values
2929
centers = np.uint8(centers)
3030

31+
# flatten the labels array
32+
labels = labels.flatten()
33+
3134
# convert all pixels to the color of the centroids
32-
segmented_image = centers[labels.flatten()]
35+
segmented_image = centers[labels]
3336

3437
# reshape back to the original image dimension
3538
segmented_image = segmented_image.reshape(image.shape)
@@ -38,10 +41,14 @@
3841
plt.imshow(segmented_image)
3942
plt.show()
4043

41-
# disable only the cluster number 2
44+
# disable only the cluster number 2 (turn the pixel into black)
4245
masked_image = np.copy(image)
46+
# convert to the shape of k clusters
47+
masked_image = masked_image.reshape((-1, k))
4348
masked_image[labels == 2] = [0, 0, 0]
4449

50+
# convert back to original shape
51+
masked_image = masked_image.reshape(image.shape)
4552
# show the image
4653
plt.imshow(masked_image)
4754
plt.show()
Collapse file

‎machine-learning/stock-prediction/README.md‎

Copy file name to clipboardExpand all lines: machine-learning/stock-prediction/README.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
To run this:
44
- `pip3 install -r requirements.txt`
5-
- Please read the tutorial before using this, edit `parameters.py` for your needs and run `train.py`. This will start training using the parameters you specified, you can use `tensorboard` on `logs` folder to visualize your training process.
5+
- Please read the [tutorial](https://www.thepythoncode.com/article/stock-price-prediction-in-python-using-tensorflow-2-and-keras) before using this, edit `parameters.py` for your needs and run `train.py`. This will start training using the parameters you specified, you can use `tensorboard` on `logs` folder to visualize your training process.
66
- Once you trained your model, use `test.py` to evaluate and test your model.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.