基于DNN的衣服评分算法
智能衣柜项目推荐模块早期版本。
import tensorflow as tf
import pandas as pd
import numpy as np
from sklearn.metrics import mean_squared_error
#参数设置
CSV_COLUMN_NAMES = ['id','Type','Color', 'Occasion', 'Weather','Goal']
#归一化
def normalization(x):
max_value = np.max(x, axis=0).reshape((1, -1))
min_value = np.min(x, axis=0).reshape((1, -1))
outputs = (x - min_value) / (max_value - min_value)
# print(max_value - min_value)
return outputs, max_value, min_value
# 反归一化
def inverse_normalization(x, max_value, min_value):
interval = np.abs(max_value - min_value)
temp = x * interval
outputs = temp + min_value
return outputs
def rmse(predictions, targets):
return np.sqrt(mean_squared_error(predictions, targets))
def mse(predictions, targets):
return mean_squared_error(predictions, targets)
# 读取文件数据
def readData():
train = pd.read_csv('cc2.csv',names=CSV_COLUMN_NAMES,header=0)
X = []
Y = []
for i in range(train.shape[0]):
X.append(train.<