Download logisticregression from bartmiller/helloworld: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/bartmiller/helloworld/resolve/main/logisticregression
- Command line
-
hf download hf://bartmiller/helloworld/logisticregression
-
curl -L -o logisticregression https://huggingface.co/bartmiller/helloworld/resolve/main/logisticregression
1 kB
| import sklearn | |
| from sklearn import datasets | |
| import numpy as np | |
| iris = datasets.load_iris() | |
| digits = datasets.load_digits() | |
| from sklearn.datasets import load_iris | |
| iris_data = load_iris() | |
| print(iris_data.data[0]) # Feature values for first sample | |
| print(iris_data.target[0]) # Target value for first sample | |
| # The imputer replaces missing values with the mean | |
| from sklearn.impute import SimpleImputer | |
| imputer = SimpleImputer(strategy='mean') | |
| imputed_data = imputer.fit_transform(iris_data.data) | |
| # Feature Scaling | |
| from sklearn.preprocessing import StandardScaler | |
| scaler = StandardScaler() | |
| scaled_data = scaler.fit_transform(iris_data.data) | |
| # Visualizing the Data | |
| import matplotlib.pyplot as plt | |
| plt.scatter(iris_data.data[:, 0], iris_data.data[:, 1], c=iris_data.target) | |
| plt.xlabel('Sepal Length') | |
| plt.ylabel('Sepal Width') | |
| plt.show() | |
| # Training a Simple Model | |
| from sklearn.linear_model import LogisticRegression | |
| model = LogisticRegression() | |
| model.fit(scaled_data, iris_data.target) | |