This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""DS Agent - Walmart Stocks Data 2025 (Unfiltered).ipynb | |
Automatically generated by Colab. | |
Original file is located at | |
https://colab.research.google.com/drive/1xQPflL75hlDCGRRntyEBdSt_DgegxlTi | |
# Task | |
Hey Data Science Agent, can you help with the data analysis on this dataset? It includes EDA, descriptive stats, and some data visualizations. If you can, could you also suggest some time-series modeling? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import azureml.core | |
# Display the core SDK version number | |
print("Azure ML SDK Version: ", azureml.core.VERSION) | |
# Define an environment | |
from azureml.core.environment import Environment | |
from azureml.core.conda_dependencies import CondaDependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import azureml.core | |
# Display the core SDK version number | |
print("Azure ML SDK Version: ", azureml.core.VERSION) | |
# Define an environment | |
from azureml.core.environment import Environment | |
from azureml.core.conda_dependencies import CondaDependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%writefile score.py | |
import json | |
import numpy as np | |
import os | |
import pickle | |
import joblib | |
def init(): | |
global model | |
################################################################################################## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import libraries | |
import json | |
import numpy as np | |
from azureml.core.model import Model | |
import joblib | |
# Load model | |
model_path = Model.get_model_path(model_name="sklearn_regression_model.pkl") | |
model = joblib.load(model_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get hold of the current run | |
run = Run.get_context() | |
# Experiment parameters | |
args = { | |
"n_estimators": 120 | |
} | |
reg_model = RandomForestRegressor(**args) | |
reg_model.fit(data["train"]["X"], data["train"]["y"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load data in Pandas | |
df = dataset.to_pandas_dataframe() | |
print(df.shape) | |
df.head() | |
# Preprocess data | |
df = df.drop_duplicates() | |
df = df.drop(["dateCrawled","dateCreated","lastSeen", "seller", "name", "postalCode"] , axis = 1) | |
df["notRepairedDamage"] = df["notRepairedDamage"].fillna("nein") | |
df["fuelType"] = df["fuelType"].fillna("benzin") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install H2O packages | |
if ("package:h2o" %in% search()) { detach("package:h2o", unload=TRUE) } | |
if ("h2o" %in% rownames(installed.packages())) { remove.packages("h2o") } | |
pkgs <- c("RCurl","jsonlite") | |
for (pkg in pkgs) { | |
if (! (pkg %in% rownames(installed.packages()))) { install.packages(pkg) } | |
} | |
install.packages("h2o", type="source", repos=(c("http://h2o-release.s3.amazonaws.com/h2o/latest_stable_R"))) | |
library(h2o) | |
localH2O = h2o.init() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the datastore to upload prepared data | |
datastore = ws.get_default_datastore() | |
# Upload the local file from src_dir to the target_path in datastore | |
datastore.upload(src_dir='../aml-kaggle/datasets/', target_path='ds_regression') | |
# Create a dataset referencing the cloud location | |
dataset = Dataset.Tabular.from_delimited_files(datastore.path('ds_regression/autos.csv')) | |
# Register a dataset |
NewerOlder