线性回归代码实现:Python版

2021-01-14 09:50:45 浏览数 (1)

文章目录

  • 线性回归代码实现
    • 代码实现
    • 图象

线性回归代码实现

代码实现

代码语言:javascript复制
#! /bin/python3
# -*-encoding="utf-8"-*-
# __Author__ ="ErrolYan"
# __Time__="2018.12.23"


from argparse import Namespace
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from sklearn.linear_model.stochastic_gradient import SGDRegressor
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt

# Arguments
args = Namespace(
    seed=1234,
    data_file="sample_data.csv",
    num_samples=100,
    train_size=0.75,
    test_size=0.25,
    num_epochs=100,
)

# Set seed for reproducability
np.random.seed(args.seed)

# Generate synthetic data Function
def generate_data

0 人点赞