- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
背景:我正在开发一个项目,旨在使用 Azure ML 中的情绪分析将产品评论分为正面和负面。当我将评论分类到不同的部门时,我陷入了困境。
我基本上是从 csv 文件中读取单词并检查评论(v:句子列表)是否包含这些单词。如果在评论中找到其中一些单词,那么我会记下句子编号并将其插入相应的列表(FinanceList、QualityList、LogisticsList)中。最后,我将列表转换为字符串并将它们推送到数据帧中。
未记录我在 Azure ML 脚本中编写的打印语句的输出。
数据帧中的值始终为 0,但是当我在本地运行代码时,我得到了预期的输出。
第一个图像的描述:数据帧的列显示 0 值。
第二张图片的描述:我突出显示了我在本地获得的预期输出,以进行与 AzureML 中使用的相同审查。
我已经检查过的事情:
我无法理解我哪里出了问题。
'
import csv
import math
import pandas as pd
import numpy as np
def azureml_main( data, ud):
FinanceDept = []
LogisticsDept = []
QualityDept = []
#Reading from the csv files
with open('.\Script Bundle\\quality1.csv', 'rb') as fin:
reader = csv.reader(fin)
QualityDept = list(reader)
with open('.\Script Bundle\\finance1.csv', 'rb') as f:
reader = csv.reader(f)
FinanceDept = list(reader)
with open('.\Script Bundle\\logistics1.csv', 'rb') as f:
reader = csv.reader(f)
LogisticDept = list(reader)
FinanceList = []
LogisticsList = []
QualityList = []
#Initializing the Lists
FinanceList.append(0)
LogisticsList.append(0)
QualityList.append(0)
rev = data['Data']
v = rev[0].split('.')
print FinanceDept
S = 0
for sentence in v:
S = S + 1
z = sentence.split(' ')
for c in z:
c = c.lower()
if c in FinanceDept and S not in FinanceList:
FinanceList.append(S)
if c in LogisticsDept and S not in LogisticsList:
LogisticsList.append(S)
if c in QualityDept and S not in QualityList:
QualityList.append(S)
#Compute User Reputation Score
Upvotes = int(ud['upvotes'].tolist()[0])
Downvotes = int(ud['downvotes'].tolist()[0])
TotalVotes = max(1,Upvotes+Downvotes)
q = data['Score']
print FinanceList
repScore = float(Upvotes)/TotalVotes
repScore = repScore*float( q[0] )
str1 = ','.join(str(e) for e in FinanceList)
str2 = ','.join(str(e) for e in QualityList)
str3 = ','.join(str(e) for e in LogisticsList)
x = ud['id']
#df = pd.DataFrame( [str(repScore), str1 , str2 , str3 ], columns=[Write the columns])
d = {'id': x[0], 'Score': float(repScore),'Logistics':str3,'Finance':str1,'Quality':str2}
df = pd.DataFrame(data=d, index=np.arange(1))
return df,`
最佳答案
@Anuj Shankar,经过同事测试,我们可以从CSV
文件中读取数据,得到预期的结果。请引用此经验:
1) 输入数据 - 它有 apple.zip
文件,其中有两个与您相似的 csv
文件,每个 csv 文件包含与公司相关的词袋。
# The script MUST contain a function named azureml_main
# which is the entry point for this module.
#
# The entry point function can contain up to two input arguments:
# Param<dataframe1>: a pandas.DataFrame
# Param<dataframe2>: a pandas.DataFrame
import csv
import numpy as np
import pandas as pd
def azureml_main(dataframe1 = None, dataframe2 = None):
# Execution logic goes here
#print('Input pandas.DataFrame #1:\r\n\r\n{0}'.format(dataframe1))
# If a zip file is connected to the third input port is connected,
# it is unzipped under ".\Script Bundle". This directory is added
# to sys.path. Therefore, if your zip file contains a Python file
# mymodule.py you can import it using:
# import mymodule
apple = {}
microsoft = {}
#Reading from the csv files
with open('.\Script Bundle\\apple.csv', 'rb') as f:
reader = csv.reader(f)
apple = list_to_dict(list(reader)[0])
with open('.\Script Bundle\\microsoft.csv', 'rb') as f:
reader = csv.reader(f)
microsoft = list_to_dict(list(reader)[0])
# print('hello world' + ' '.join(apple[0]))
applecount = 0
microsoftcount = 0
input = "i want to buy surface which runs on windows"
splitted_input = input.split(' ')
for word in splitted_input:
if word in apple:
applecount = applecount + 1
if word in microsoft:
microsoftcount = microsoftcount + 1
print("apple bag of words count - " + str(applecount))
print("microsoft bag of words count - " + str(microsoftcount))
mydata = [{'input words': len(splitted_input)}, {'applecount':applecount},
{'microsoftcount':microsoftcount}]
# Return value must be of a sequence of pandas.DataFrame
return pd.DataFrame(mydata),
def list_to_dict(li):
dct = {}
for item in li:
if dct.has_key(item):
dct[item] = dct[item] + 1
else:
dct[item] = 1
return dct
3) 输出 - 如果我考虑一个字符串“我想购买在 Windows 上运行的表面”。它有 2 个与 microsoft 相关的单词和 0 个与 apple 相关的单词,如下面的快照所示。
关于python - 在 AzureML 中未获得预期输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32431471/
我正在尝试使用 AMLCompute 实例来预处理我的数据。为此,我需要能够将处理后的数据写回数据存储。我采用这种方法是因为集群在完成后会自动关闭,这样我就可以让它运行直到完成,而不必担心付出比需要更
我使用 PythonScriptStep 制作了两个脚本,其中 data_prep.py 通过执行一些数据转换来准备数据集,然后将其发送到 train.py 以在 AzureML 中训练 ML 模型。
我试图使用 Run 类注册一个模型,如下所示: model = run.register_model( model_name=model_name, model_path=model_
我使用 PythonScriptStep 制作了两个脚本,其中 data_prep.py 通过执行一些数据转换来准备数据集,然后将其发送到 train.py 以在 AzureML 中训练 ML 模型。
我试图使用 Run 类注册一个模型,如下所示: model = run.register_model( model_name=model_name, model_path=model_
我需要使用 Azure 机器学习来开发管道。在此管道中,我们不将数据作为输入/输出传递,而是传递变量(例如列表或整数)。我查看了 Microsoft 文档,但似乎找不到适合我的情况的内容。还尝试使用
如果我在 Hadoop 集群或 SQL Elastic DB 中有数据,ML 是否会将这些数据带到 ML 服务器上,或者将其留在 Hadoop/sql 上并在那里运行分析? 最佳答案 目前,Azure
我正在尝试创建一个流程,作为不同的实验进行训练测试分割、训练、验证、获得最佳模型(在 8 个差异算法中)并进行预测。问题是我需要创建实验的依赖性,并且我需要这方面的帮助。我知道 azure ml 管道
我正在尝试创建一个流程,作为不同的实验进行训练测试分割、训练、验证、获得最佳模型(在 8 个差异算法中)并进行预测。问题是我需要创建实验的依赖性,并且我需要这方面的帮助。我知道 azure ml 管道
我想知道 Azure 机器学习工作室中的feature numeric 和 numeric 列有什么区别。 documentation site状态: Because all columns are
我想使用 AzureML 执行超参数搜索。我的模型很小(大约 1GB),因此我想在同一个 GPU/节点上运行多个模型以节省成本,但我不知道如何实现这一点。 我当前提交作业的方式如下(导致每个 GPU/
我正在使用 Python SDK 将经过训练的模型部署到 Azure 机器学习上的 ACI 端点。 我已经创建了我的 score.py 文件,但我希望通过传递的参数调用该文件(就像使用训练文件一样),
我可以使用 Run.log 记录和获取指标到 AzureML,但是,我还需要一种方法来记录运行参数,例如学习率或动量。我似乎无法在 AzureML Python SDK 文档中找到任何内容来实现此目的
这是一种将运行 ID 与 Blob 存储链接起来的方法吗?我知道如何查找每个步骤的信息,这些信息存储在 default blob > azureml > ExperimentRun > dcid.st
我正在尝试通过 sdk 安装数据存储,如下所示 import tempfile import os mounted_path = tempfile.mkdtemp() mount_context =
我已经在 AzureML Designer 上构建了一个管道,并且正在尝试使用管道参数,但我无法在 python 脚本模块上获取这些参数的值。 https://learn.microsoft.com/
我有一个名为 data 的文件夹,里面有一堆 csv(大约 80 个),文件大小相当小。该数据是干净的并且已经过预处理。我想上传此数据文件夹并在 azureml 中注册为数据存储。对于这种情况,使用文
背景:我正在开发一个项目,旨在使用 Azure ML 中的情绪分析将产品评论分为正面和负面。当我将评论分类到不同的部门时,我陷入了困境。 我基本上是从 csv 文件中读取单词并检查评论(v:句子列表)
在 Azure 数据工厂中使用 AzureMLBatchExecution 事件时,将数据库查询作为全局参数传递给 AzureML Web 服务是否安全? 最佳答案 当您谈论“安全”时,您是否担心 A
使用 Azure 设计器创建模型并创建实时推理管道后,我想在本地脚本中使用经过训练的工件。我试图在 Azure 存储资源管理器中查找 model.py,但找不到它,也找不到使用 pytorch 调用训
我是一名优秀的程序员,十分优秀!