提供一些使用Python进行机器学习的示例代码。
以下是几个使用Python进行机器学习的示例代码：

1. 线性回归

```python
from sklearn.linear_model import LinearRegression

# 训练集数据
X_train = [[1, 1], [2, 2], [3, 3], [4, 4]]
y_train = [2, 4, 6, 8]

# 创建线性回归对象
lin_reg = LinearRegression()

# 训练模型
lin_reg.fit(X_train, y_train)

# 预测新数据
X_test = [[5, 5]]
y_predict = lin_reg.predict(X_test)
print(y_predict) # 输出 [10.]
```

2. 决策树

```python
from sklearn.tree import DecisionTreeClassifier
from sklearn import datasets
from sklearn.model_selection import train_test_split

# 加载 iris 数据集
iris = datasets.load_iris()

# 划分数据集
X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.3)

# 创建决策树对象
clf = DecisionTreeClassifier()

# 训练模型
clf.fit(X_train, y_train)

# 预测数据
y_predict = clf.predict(X_test)
print(y_predict) # 输出预测结果

# 计算准确率
score = clf.score(X_test, y_test)
print(score) # 输出准确率
```

3. 神经网络

```python
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers

# 加载 MNIST 数据集
mnist = tf.keras.datasets.mnist

# 划分数据集
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()

# 归一化数据
train_images = train_images / 255.0
test_images = test_images / 255.0

# 创建模型
model = keras.Sequential([
    layers.Flatten(input_shape=(28, 28)),
    layers.Dense(128, activation='relu'),
    layers.Dense(10)
])

# 编译模型
model.compile(optimizer='adam',
              loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
              metrics=['accuracy'])

# 训练模型
model.fit(train_images, train_labels, epochs=10, validation_data=(test_images, test_labels))

# 评估模型
test_loss, test_acc = model.evaluate(test_images, test_labels)
print('Test accuracy:', test_acc)
```