【发布时间】:2015-01-28 06:55:52
【问题描述】:
我正在尝试使用 scikit-learn 对从 Ebay API 获得的数据进行预测。我想知道将这些数据转换为可用于 scikit-learn 的多类分类问题的格式的最佳方法。它解释在 scikit-learn 网站上导入外部数据的唯一方法似乎是从 svmlight 文件加载,如下所示:
http://scikit-learn.org/stable/datasets/
我想将数据用于多种算法,而不仅仅是 SVM。我使用以下代码将数据保存在 dict 对象中:
from ebaysdk.finding import Connection as Finding
from requests.exceptions import ConnectionError
try:
api = Finding(appid="my_app_id")
api_request = {'keywords': 'Samsung Galaxy S5 G900R4 16GB', 'itemFilter': [{'name': 'SoldItemsOnly',
'value': 'true'}], 'outputSelector': 'SellerInfo', 'GLOBAL-ID': 'EBAY- GB'}
response = api.execute('findCompletedItems', api_request)
#print(response.dict())
except ConnectionError as e:
print(e)
print(e.response.dict())
我在网上搜索了有关如何执行此操作的教程或说明,但我找不到任何有用的信息,其中详细介绍了如何将数据转换为我需要的格式以及究竟是什么格式需要。
请有人给我一些指导,说明我是否应该使用 svmlight 文件来实现这一点以及如何去做,或者是否有任何其他关于导入我的数据的建议。我是机器学习的新手,因为以及 Python 和 scikit-learn,因此非常感谢您的帮助。
以下是原始数据格式的示例:
{'autoPay': 'true',
'condition': {'conditionDisplayName': 'Used', 'conditionId': '3000'},
'country': 'US',
'galleryURL': 'http://thumbs4.ebaystatic.com/m/mO-HwGeodkgYX6sRbPyFsrg/140.jpg',
'globalId': 'EBAY-US',
'isMultiVariationListing': 'false',
'itemId': '201265198351',
'listingInfo': {'bestOfferEnabled': 'false',
'buyItNowAvailable': 'false',
'endTime': '2015-01-16T00:23:19.000Z',
'gift': 'false',
'listingType': 'StoreInventory',
'startTime': '2015-01-15T15:47:38.000Z'},
'location': 'Dandridge,TN,USA',
'paymentMethod': 'PayPal',
'postalCode': '37725',
'primaryCategory': {'categoryId': '9355',
'categoryName': 'Cell Phones & Smartphones'},
'productId': {'_type': 'ReferenceID', 'value': '182557948'},
'returnsAccepted': 'true',
'sellerInfo': {'feedbackRatingStar': 'Turquoise',
'feedbackScore': '445',
'positiveFeedbackPercent': '100.0',
'sellerUserName': 'dadscritter15'},
'sellingStatus': {'convertedCurrentPrice': {'_currencyId': 'USD',
'value': '279.99'},
'currentPrice': {'_currencyId': 'USD', 'value': '279.99'},
'sellingState': 'Ended'},
'shippingInfo': {'expeditedShipping': 'true',
'handlingTime': '2',
'oneDayShippingAvailable': 'false',
'shipToLocations': ['US',
'CA',
'GB',
'AU',
'AT',
'BE',
'FR',
'DE',
'IT',
'JP',
'ES',
'CH',
'NL',
'CN',
'HK',
'MX'],
'shippingServiceCost': {'_currencyId': 'USD', 'value': '0.0'},
'shippingType': 'FlatDomesticCalculatedInternational'},
'title': 'Samsung Galaxy S5 SM-G900R4 (Latest Model) 16GB White (U.S. Cellular) Verify ESN',
'topRatedListing': 'false',
'viewItemURL': 'http://www.ebay.com/itm/Samsung-Galaxy-S5-SM-G900R4-Latest-Model-16GB-White-U-S-Cellular-Verify-ESN-/201265198351?pt=LH_DefaultDomain_0'},
{'autoPay': 'true',
'condition': {'conditionDisplayName': 'Used', 'conditionId': '3000'},
'country': 'US',
'galleryURL': 'http://thumbs4.ebaystatic.com/m/mO-HwGeodkgYX6sRbPyFsrg/140.jpg',
'globalId': 'EBAY-US',
'isMultiVariationListing': 'false',
'itemId': '201265198351',
'listingInfo': {'bestOfferEnabled': 'false',
'buyItNowAvailable': 'false',
'endTime': '2015-01-16T00:23:19.000Z',
'gift': 'false',
'listingType': 'StoreInventory',
'startTime': '2015-01-15T15:47:38.000Z'},
'location': 'Dandridge,TN,USA',
'paymentMethod': 'PayPal',
'postalCode': '37725',
'primaryCategory': {'categoryId': '9355',
'categoryName': 'Cell Phones & Smartphones'},
'productId': {'_type': 'ReferenceID', 'value': '182557948'},
'returnsAccepted': 'true',
'sellerInfo': {'feedbackRatingStar': 'Turquoise',
'feedbackScore': '445',
'positiveFeedbackPercent': '100.0',
'sellerUserName': 'dadscritter15'},
'sellingStatus': {'convertedCurrentPrice': {'_currencyId': 'USD',
'value': '279.99'},
'currentPrice': {'_currencyId': 'USD', 'value': '279.99'},
'sellingState': 'Ended'},
'shippingInfo': {'expeditedShipping': 'true',
'handlingTime': '2',
'oneDayShippingAvailable': 'false',
'shipToLocations': ['US',
'CA',
'GB',
'AU',
'AT',
'BE',
'FR',
'DE',
'IT',
'JP',
'ES',
'CH',
'NL',
'CN',
'HK',
'MX'],
'shippingServiceCost': {'_currencyId': 'USD', 'value': '0.0'},
'shippingType': 'FlatDomesticCalculatedInternational'},
'title': 'Samsung Galaxy S5 SM-G900R4 (Latest Model) 16GB White (U.S. Cellular) Verify ESN',
'topRatedListing': 'false',
'viewItemURL': 'http://www.ebay.com/itm/Samsung-Galaxy-S5-SM-G900R4-Latest-Model-16GB-White-U-S-Cellular-Verify-ESN-/201265198351?pt=LH_DefaultDomain_0'}
【问题讨论】:
-
svmlight 文件格式之所以这样调用,是因为它遵循
svmlight程序的约定。这并不限制您使用哪种算法。 -
所以我想这可能是我需要使用的格式,谢谢。
标签: python machine-learning scikit-learn