简体   繁体   中英

Azure Machine Learning - python

I have program an algorithm in python for azure ML, but I don't get it to run. I did program it by Visual Studio (PTVS). I take this code to get the same condition like in 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. Description of the same Problem, but in an other way, do you find here: forum of azure ML .

My full code, which I want to implement have lists with up to 4 dimensionen or more. (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

PS: Excuse me for my bad English please :-)

Edit: PPS: The full Code, which I have in the module Python Code Script:

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!

Per my experience, The issue was caused by the function azureMLstartCondition load the dataset from the CSV file at your local path.

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.

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/ ).

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.

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/ .


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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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