从sklearn导入train_test_split时出现scipy库错误

时间:2017-07-14 12:15:48

标签: python machine-learning scipy scikit-learn

我正在应用implementing recommendation system的这个教程,当我从sklearn.selection_model train_test_split导入以进行训练/测试分割时,我遇到了一个问题。

import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split

#create columns name
header = ['user_id', 'item_id', 'rating', 'timestamp']
#read data containing the full dataset of ratings
df = pd.read_csv('ml-100k/u.data', sep='\t', names=header)

n_users = df.user_id.unique().shape[0]
n_items = df.item_id.unique().shape[0]

print 'Number of users = ' + str(n_users) + ' | Number of movies = ' + str(n_items)
#train_data, test_data = train_test_split(df,test_size=0.25)

#print 'train shape = ' + str(train_data.shape)

记录错误:

  

追踪(最近一次通话):     文件" C:/Users/PycharmProjects/recommendation_system_trials/engine.py" ;,第3行,在       来自sklearn.model_selection import train_test_split     文件" C:\ Users \ hello2 \ lib \ site-packages \ sklearn__init __。py",第57行,in       来自.base导入克隆     文件" C:\ Users \ hello2 \ lib \ site-packages \ sklearn \ base.py",第10行,in       从scipy导入稀疏   ImportError:没有名为scipy的模块

为什么我收到此错误,我没有使用scipy,我只想导入train_test_split。

感谢您的帮助。

0 个答案:

没有答案