File size: 562 Bytes
b6beed8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# -*- coding: utf-8 -*-
"""Machine learning: scikit-learn, torch"""
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
import torch

# scikit-learn example
iris = load_iris()
X, y = iris.data, iris.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
clf = RandomForestClassifier()
clf.fit(X_train, y_train)
print("sklearn accuracy:", clf.score(X_test, y_test))

# PyTorch example
x = torch.tensor([1.0, 2.0, 3.0])
print("pytorch tensor:", x)