Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit581f669

Browse files
committed
added stock prediction README & fixed kmeans tutorial code
1 parent1f46e8e commit581f669

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

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

Lines 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()

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

Lines changed: 1 addition & 1 deletion
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)

[8]ページ先頭

©2009-2025 Movatter.jp