Supervised Learning Algorithms in Machine Learning
k-Nearest Neighbors Algorithm
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from math import sqrt
plt.rcParams['font.sans-serif'] = ['Simhei']
wine_data = {'color_intensity': [14.13, 13.2, 13.16, 14.27, 13.24, 12.07, 12.43, 11.79, 12.37, 12.04],
'alcohol_content': [5.64, 4.28, 5.68, 4.80, 4.22, 2.76, 3.94 ...
Posted on Wed, 22 Jul 2026 16:30:59 +0000 by tyrol_gangster
Sales Forecasting Using Linear Regression
Predict sales for November and December 2018.
import glob
import os
import pandas as pd
import re
import numpy as np
import datetime as dt
from sklearn.linear_model import LinearRegression
import seaborn as sns
from matplotlib import pyplot as plt
# Set font for Chinese characters
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axe ...
Posted on Fri, 10 Jul 2026 16:43:59 +0000 by Elhombrebala
Implementing Softmax Regression from Scratch with PyTorch
import torch
# Initialize a tensor with gradient tracking
x = torch.tensor([1.0, 2.0, 3.0, 4.0], requires_grad=True)
# Compute a scalar output
y = 3 * torch.dot(x, x)
# Backpropagation
y.backward()
# Display gradients
print(f"Input tensor: {x}")
print(f"Gradients: {x.grad}")
Gradinet Management
# Zero out gradients b ...
Posted on Wed, 20 May 2026 04:57:19 +0000 by AngusL