У меня проблема с точностью и потерями при построении ИНС для прогнозирования продаж видеоигр. Потери очень высоки, как 4.3, а точность застряла на 0. Любая помощь будет принята с благодарностью.
import tensorflow as tf
import pandas as pd
import numpy as np
from tensorflow.keras.layers import Dense, Dropout
from tensorflow.keras.models import Model
dataset = pd.read_csv('Train.csv')
#dropping one outlier
dataset = dataset.drop(dataset[(dataset['SalesInMillions']>60)].index)
X = dataset.iloc[:,3:8]
Y = dataset['SalesInMillions'].values
dataset.drop('SalesInMillions', axis=1, inplace=True)
#getting dummy variables for categorical values - Rating, Category
print(dataset.shape) #pre-dummies shape
dataset = pd.get_dummies(data=dataset, columns=['CATEGORY', 'RATING'])
print(dataset.shape) #post-dummies shape
dataset.head() #Check to verify that dummies are ok
from sklearn.preprocessing import LabelEncoder
le = LabelEncoder()
dataset['le_publisher'] = le.fit_transform(dataset['PUBLISHER'])
dataset.head()
X = dataset.iloc[:,4:]
"""#Model Building"""
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X,Y, test_size=0.33, random_state=42)
print(X_train.shape, X_test.shape, y_train.shape, y_test.shape)
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)
y_train = y_train.reshape(-1, 1)
y_test = y_test.reshape(-1, 1)
model = tf.keras.models.Sequential([
Dense(32, input_shape=X_train[0].shape, activation='relu'),
Dense(64, activation='relu'),
Dense(128, activation='relu'),
Dense(1)
])
model.compile(optimizer='adam', loss='mse', metrics=['accuracy'])
model.summary()
r = model.fit(X_train, y_train, validation_data=(X_test, y_test), epochs=10)
Результат:
>Epoch 1/10
74/74 [==============================] - 0s 3ms/step - loss: 5.3924 - accuracy: 0.0000e+00 - val_loss: 3.1689 - val_accuracy: 0.0000e+00
>Epoch 2/10
74/74 [==============================] - 0s 3ms/step - loss: 4.7189 - accuracy: 0.0000e+00 - val_loss: 3.1634 - val_accuracy: 0.0000e+00
>Epoch 3/10
74/74 [==============================] - 0s 3ms/step - loss: 4.6166 - accuracy: 0.0000e+00 - val_loss: 3.0874 - val_accuracy: 0.0000e+00
>Epoch 4/10
74/74 [==============================] - 0s 2ms/step - loss: 4.5860 - accuracy: 0.0000e+00 - val_loss: 3.0585 - val_accuracy: 0.0000e+00
>Epoch 5/10
74/74 [==============================] - 0s 2ms/step - loss: 4.5070 - accuracy: 0.0000e+00 - val_loss: 3.1005 - val_accuracy: 0.0000e+00