第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

sklearn MinMaxScaler - ValueError:預(yù)期的二維數(shù)組

sklearn MinMaxScaler - ValueError:預(yù)期的二維數(shù)組

繁華開滿天機(jī) 2023-04-18 14:45:00
我想在分析之前使用MinMaxScalerfrom來縮放測(cè)試和訓(xùn)練數(shù)據(jù)。sklearn我一直在學(xué)習(xí)教程 ( https://mc.ai/an-introduction-on-time-series-forecasting-with-simple-neura-networks-lstm/ ),但我收到一條錯(cuò)誤消息ValueError: Expected 2D array, got 1D array instead。我嘗試查看Print predict ValueError: Expected 2D array, got 1D array instead,但如果我嘗試train = train.reshape(-1, 1)或test = test.reshape(-1, 1)因?yàn)樗鼈兪窍盗校視?huì)收到一條錯(cuò)誤消息(錯(cuò)誤消息AttributeError: 'Series' object has no attribute 'reshape')我該如何最好地解決這個(gè)問題?# Import libraries import pandas as pd from sklearn.preprocessing import MinMaxScaler # Create MWE dataset data = [['1981-11-03', 510], ['1982-11-03', 540], ['1983-11-03', 480],   ['1984-11-03', 490], ['1985-11-03', 492], ['1986-11-03', 380],   ['1987-11-03', 440], ['1988-11-03', 640], ['1989-11-03', 560],    ['1990-11-03', 660], ['1991-11-03', 610], ['1992-11-03', 480]] df = pd.DataFrame(data, columns = ['Date', 'Tickets']) # Set 'Date' to datetime data type df['Date'] = pd.to_datetime(df['Date'])# Set 'Date to index   df = df.set_index(['Date'], drop=True)# Split dataset into train and test  split_date = pd.Timestamp('1989-11-03')df =  df['Tickets']train = df.loc[:split_date]test = df.loc[split_date:]# Scale train and test data scaler = MinMaxScaler(feature_range=(-1, 1))train_sc = scaler.fit_transform(train)test_sc = scaler.transform(test)X_train = train_sc[:-1]y_train = train_sc[1:]X_test = test_sc[:-1]y_test = test_sc[1:]# ERROR MESSAGE   ValueError: Expected 2D array, got 1D array instead:  array=[510. 540. 480. 490. 492. 380. 440. 640. 560.].  Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
查看完整描述

目前暫無任何回答

  • 0 回答
  • 0 關(guān)注
  • 278 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)