diff --git a/01.00. - Me/🏪 訂閱.md b/01.00. - Me/🏪 訂閱.md new file mode 100644 index 0000000..c6f2ff4 --- /dev/null +++ b/01.00. - Me/🏪 訂閱.md @@ -0,0 +1,21 @@ +--- +tags: +aliases: +date: 2025-03-02 +time: 20:48:27 +description: +--- + +# 目前訂閱 +- Apple Music, $320 +- Netflix, $420 + + +# 考慮訂閱 +- Felo +- Grok +- ChatGPT +- Kagi + + +# 參考來源 \ No newline at end of file diff --git a/00. Inbox/🤷♂️想買的東西.md b/01.00. - Me/🤷♂️ 想買的東西.md similarity index 100% rename from 00. Inbox/🤷♂️想買的東西.md rename to 01.00. - Me/🤷♂️ 想買的東西.md diff --git a/01. 輸出/人腦使用手冊.md b/01.01. 輸出/人腦使用手冊.md similarity index 100% rename from 01. 輸出/人腦使用手冊.md rename to 01.01. 輸出/人腦使用手冊.md diff --git a/01. 輸出/把 Flask 包裝成 EXE 檔.md b/01.01. 輸出/把 Flask 包裝成 EXE 檔.md similarity index 100% rename from 01. 輸出/把 Flask 包裝成 EXE 檔.md rename to 01.01. 輸出/把 Flask 包裝成 EXE 檔.md diff --git a/10. 日記/2024/05/2024-05-23(週四).md b/10. 日記/2024/05/2024-05-23(週四).md index 23cd53d..4ef8e23 100644 --- a/10. 日記/2024/05/2024-05-23(週四).md +++ b/10. 日記/2024/05/2024-05-23(週四).md @@ -13,7 +13,7 @@ description: # 今日發生什麼事? 想要擺脫手機的想法愈來愈大,可是又覺得沒辦法完全擺脫,感覺會變成脫節的人、古板的人,先讓自己一天看幾次手機就好。 -想要買 Makita [[🤷♂️想買的東西#DCF301|DCF301]],就覺得出門在外的時候可以用,可是真的有那麼需要嗎?我的買買病感覺又發作了。 +想要買 Makita [[🤷♂️ 想買的東西#DCF301|DCF301]],就覺得出門在外的時候可以用,可是真的有那麼需要嗎?我的買買病感覺又發作了。 # 有什麼想法? diff --git a/21.01. Programming/Python/Write a Package.md b/21.01. Programming/Python/Write a Package.md new file mode 100644 index 0000000..985fa91 --- /dev/null +++ b/21.01. Programming/Python/Write a Package.md @@ -0,0 +1,173 @@ +--- +tags: +aliases: +date: 2025-03-02 +time: 20:53:47 +description: +--- + +# Project Structure +``` +mlpredictor/ +│ +├── mlpredictor/ +│ ├── __init__.py +│ ├── model.py +│ +├── tests/ +│ ├── test_model.py +│ +├── LICENSE +├── README.md +├── pyproject.toml +└── .gitignore +``` + + +## Content of `setup.py` +``` +from setuptools import setup + +setup( +name='mypackage', +version='0.1', +packages=['mypackage'], +install_requires=['requests']) +``` + +## Content of `pyproject.toml` +```toml +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "mlpredictor" +version = "0.1.0" +description = "A simple machine learning package using scikit-learn" +authors = [ +{name = "Ebrahim", email = "ebimsv0501@gmail.com"} +] +license = {text = "MIT"} +readme = "README.md" +requires-python = ">=3.6" +dependencies = [ +"scikit-learn>=1.0", +] + +[project.urls] +"Homepage" = "https://github.com/ebimsv/mlpredictor" +``` +- **[build-system]**: Specifies the build system requirements (i.e., using `setuptools` and `wheel`). +- **[project]**: Contains metadata about the package, like name, version, description, and dependencies. + + +## Content of `README.md` +
+# MLPredictor
+
+MLPredictor is a simple machine learning package that trains a RandomForest model using the Iris dataset and enables users to make predictions. The package is built using `scikit-learn` and is intended as a demonstration of packaging Python machine learning projects for distribution.
+
+## Features
+
+- Train a RandomForestClassifier on the Iris dataset.
+- Make predictions on new data after training.
+- Save and load trained models.
+
+## Installation
+
+You can install the package via **PyPI** or from **source**.
+
+### Install from PyPI
+
+```bash
+pip install mlpredictor
+```
+
+### Install from Source (GitHub)
+
+```bash
+git clone https://github.com/ebimsv/mlpredictor.git
+cd mlpredictor
+pip install .
+```
+
+## Usage
+
+After installation, you can use `MLPredictor` to train a model and make predictions.
+
+### Example: Training and Making Predictions
+
+```python
+from mlpredictor import MLPredictor
+
+# Initialize the predictor
+predictor = MLPredictor()
+
+# Train the model on the Iris dataset
+predictor.train()
+
+# Make a prediction on a sample input
+sample_input = [5.1, 3.5, 1.4, 0.2]
+prediction = predictor.predict(sample_input)
+
+print(f"Predicted class: {prediction}")
+```
+
+
+## Content of `.gitignore`
+```
+*.pyc
+__pycache__/
+*.pkl
+dist/
+build/
+```
+
+
+# Test
+## Content of `tests/test_model.py`
+```python
+import pytest
+from mlpredictor import MLPredictor
+
+def test_train_and_predict():
+ model = MLPredictor()
+ model.train()
+ result = model.predict([5.1, 3.5, 1.4, 0.2])
+ assert len(result) == 1
+
+if __name__ == "__main__":
+ pytest.main()
+```
+
+## Run test
+```bash
+pytest tests
+```
+
+
+# Install
+## Test locally
+```
+pip install .
+```
+
+## Publish on PyPI
+1. **Install 'Twine' and 'build'**:
+```
+pip install twine build
+```
+
+2. **Build the Package**:
+```
+python -m build
+```
+
+3. **Upload to PyPI**
+```
+twine upload dist/*
+```
+
+# 參考來源
+- [Building Python Packages. A Comprehensive Guide to setup.py and… | by Ebrahim Mousavi | Medium](https://medium.com/@ebimsv/building-python-packages-07fbfbb959a9)