简体   繁体   English

Azure机器学习-python

[英]Azure Machine Learning - python

I have program an algorithm in python for azure ML, but I don't get it to run. 我已经在python中为azure ML编写了一种算法,但是我没有让它运行。 I did program it by Visual Studio (PTVS). 我是通过Visual Studio(PTVS)对其进行编程的。 I take this code to get the same condition like in azure ML: 我使用此代码来获得与Azure ML中相同的条件:

def azureMLstartCondition():
    fileLocation = 'C:/Users/nissen/Desktop/SLR-Algrorithmus/Belgian376.csv'
    dataset = pd.DataFrame(pd.read_csv(fileLocation, error_bad_lines = False))
    azureml_main(dataset)

My Code to convert the given pandas data frame into lists is: 我的代码将给定的熊猫数据框转换为列表:

def formData(dataset):

    listOfTransaction = dataset.values.tolist()

    cleanedList = []
    for transaction in listOfTransaction:
        itemList = []
        for item in transaction:
            if False ==  pd.isnull(item):
                itemList.append(item)
        cleanedList.append(itemList)

    return cleanedList

My code to turn it back into pandas data frame: 我的代码将其转换回熊猫数据框:

def formToPandas(result):
    lastStep = pd.DataFrame(result)
    return lastStep

In Visual Studio does everything work, but not in azure ML. 在Visual Studio中,一切正常,但在Azure ML中则不能。 Description of the same Problem, but in an other way, do you find here: forum of azure ML . 相同问题的描述,但以另一种方式,您是否在这里找到: azure ML论坛

My full code, which I want to implement have lists with up to 4 dimensionen or more. 我要实现的完整代码包含最多4个维度或更多的列表。 (lists of lists of lists .... ) But the last is a list of lists, that should be no problem to convert to pandas. (列表列表的列表...。)但是最后是列表列表,转换为熊猫应该没问题。

I hope you can help me, many greetings, peni4142 希望您能帮我,许多问候,peni4142

PS: Excuse me for my bad English please :-) PS:对不起,我的英语不好,请:-)

Edit: PPS: The full Code, which I have in the module Python Code Script: 编辑:PPS:完整的代码,我在模块Python代码脚本中拥有:

import pandas as pd

def formToPandas(result):
    lastStep = pd.DataFrame(result)
    return lastStep

def formData(dataset):

    listOfTransaction = dataset.values.tolist()

    cleanedList = []
    for transaction in listOfTransaction:
        itemList = []
        for item in transaction:
            if False ==  pd.isnull(item):
                itemList.append(item)
        cleanedList.append(itemList)

    return cleanedList


def allocationPhase(dataframe1):
    formedData = (formData(dataframe1))
    return formedData

def azureml_main(dataframe1 = None, dataframe2 = None):
    formToPandas(allocationPhase(dataframe1))

Maybe that will help more. 也许这会有所帮助。 Thank you very much for your help. 非常感谢您的帮助。 Ok if I had found out to implement the code this way before, I would had share it like this, before. 好吧,如果我以前发现过以这种方式实现代码,那么我之前会像这样共享它。 :D Sorry! :D对不起!

Per my experience, The issue was caused by the function azureMLstartCondition load the dataset from the CSV file at your local path. 根据我的经验,该问题是由于函数azureMLstartCondition从本地路径上的CSV文件加载数据集引起的。

On Azure ML, the dataset should be loaded from the Azure Storage thru programming in Python Storage SDK or using Data Input and Output module in MS Azure ML Studio. 在Azure ML上,应通过Python Storage SDK中的编程或使用MS Azure ML Studio中的“ Data Input and Output模块从Azure存储中加载数据集。

So I think you need to upload the existing data csv file into Azure Storage or an Azure ML experiment firstly (Please refer to https://azure.microsoft.com/en-us/documentation/articles/machine-learning-walkthrough-2-upload-data/ ). 因此,我认为您首先需要将现有的数据csv文件上传到Azure存储或Azure ML实验中(请参阅https://azure.microsoft.com/zh-cn/documentation/articles/machine-learning-walkthrough-2 -upload-data / )。

Then you can access the uploaded dataset with Python (Please refer to https://azure.microsoft.com/en-us/documentation/articles/machine-learning-python-data-access/ ) and modify your code to make it works on Azure ML. 然后,您可以使用Python访问上传的数据集(请参阅https://azure.microsoft.com/zh-cn/documentation/articles/machine-learning-python-data-access/ )并修改您的代码以使其起作用在Azure ML上。

For importing data into Azure ML, you can also refer to https://azure.microsoft.com/en-us/documentation/articles/machine-learning-data-science-import-data/ . 要将数据导入Azure ML,您还可以参考https://azure.microsoft.com/zh-cn/documentation/articles/machine-learning-data-science-import-data/


Updated for the error information of comment 更新了注释的错误信息

For the error RPackage library exception: Failed to convert RObject to DataSet , there is a troubleshooting blog http://blogs.msdn.com/b/andreasderuiter/archive/2015/02/03/troubleshooting-error-1000-rpackage-library-exception-failed-to-convert-robject-to-dataset-when-running-r-scripts-in-azure-ml.aspx to explain and resolve it for Azure ML. 对于错误的RPackage library exception: Failed to convert RObject to DataSet ,有一个故障排除博客http://blogs.msdn.com/b/andreasderuiter/archive/2015/02/03/troubleshooting-error-1000-rpackage-library在Azure-ml.aspx中运行r脚本时,异常无法将robject转换为数据集以针对Azure ML进行解释和解决。

this does work: 这确实有效:

def formData(dataset):

    listOfTransaction = list()
    listOfTransaction = dataset.values.tolist()
    cleanedList = []
    for transaction in listOfTransaction:
        itemList = []
        for item in transaction:
            if False ==  pd.isnull(item):
                itemList.append(item)
        cleanedList.append(itemList)

    return cleanedList

def formToPandas(result):
    return pd.DataFrame(result)

I wanted problem at the wrong Place. 我想在错误的地方提出问题。 The real Problem was in Visual Studio there is no Problem to make this (x/y)*100, where x is much smaller than y, but in azureML you get 0 as result, except you create the variable as x = 0.0. 真正的问题是在Visual Studio中没有问题可以使这个(x / y)* 100,其中x比y小得多,但是在azureML中,您得到的结果为0,除了将变量创建为x = 0.0外。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM