记录写的第一个深度学习网络–pytorch做回归任务
数据格式
用open-change7个变量预测label
代码
# 导入库
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import torch
from sklearn import preprocessing
# 导入数据集
# 训练集和测试集导入数据
data = pd.read_csv(r'stock_train.csv',encoding='utf-8')
data_test1 = pd.read_csv(r'stock_test.csv',encoding='utf-8')
# 导入训练集因变量
y_train = np.array(data.label)
y_train = y_train.reshape(-1, 1)
y_train = preprocessing.StandardScaler().fit_transform(y_train)
# 导入训练集自变量
data_train = data.drop('label', axis = 1)
data_train = data_train.drop(columns = 'date', axis = 1)
x_train = np.array(data_train)
x_train