机器学习大作业 新得体会_机器学习作业不会因为您盯着它们而运行得更快

机器学习大作业 新得体会

Image for post
Free-Photos from Free-PhotosPixabay Pixabay上发布

As compelling as it is, I do not have time to sit and watch long-running data pipelines clock, models train, and python scripts take care of my tasks. Often we want to be sure there wasn’t a failure that requires attention. One solution to this issue is to have an email or text sent for whatever status updates you desire. You can go off and do other tasks without worrying.

尽管引人注目,但我没有时间坐下来观看长时间运行的数据管道时钟,模型训练和python脚本来完成我的任务。 通常,我们希望确保没有需要引起关注的失败。 解决此问题的一种方法是发送电子邮件或文本以获取所需的任何状态更新。 您可以不用担心而去做其他任务。

There are several good tutorials out there on how to send emails and texts from a python script. Setup will vary depending on if you are working within an organization or on your projects. For this example, I will set up a Twilio phone number and use that account to send myself text updates during a python script run.

关于如何从python脚本发送电子邮件文本,有一些不错的教程。 设置会有所不同,具体取决于您是在组织内工作还是在项目中工作。 对于此示例,我将设置一个Twilio电话号码,并使用该帐户在python脚本运行期间向自己发送文本更新。

After setting up a Twilio account, you access your account id and API token. To send a text through the API, you need to request a Twilio phone number. This entire process takes about 2 minutes. Very fast!

设置Twilio帐户后,您可以访问帐户ID和API令牌。 要通过API发送文本,您需要请求一个Twilio电话号码。 整个过程大约需要2分钟。 非常快!

The script below is a typical machine learning type of script. In this case, an autoML script runs using the mljar package. I not only want to know when the script has completed running, but I also want to be alerted when there are failures.

以下脚本是典型的机器学习类型的脚本。 在这种情况下,将使用mljar包运行autoML脚本。 我不仅想知道脚本何时完成运行,而且还想在发生故障时得到警告。

# Example of sending text status updates while running an autoML script.import pandas as pd 
# scikit learn utilites
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split# mljar-supervised package
from supervised.automl import AutoML######################################################
# https://www.twilio.com/docs/python/install
from twilio.rest import Client# Your Account Sid and Auth Token from twilio.com/console
# DANGER! This is insecure. See http://twil.io/secure
account_sid = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
auth_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
client = Client(account_sid, auth_token)
#######################################################try:
input_df = pd.read_csv('train.csv')
input_df.fillna(0)
print('Input file columns: ' + str(input_df.columns))train_data = input_df[['id', 'keyword', 'location', 'text']]train_label = input_df[['target']]print('train data : ' + str(train_data.head(1)))
print('train label: ' + str(train_label.head(1)))X_train, X_test, y_train, y_test = train_test_split(
pd.DataFrame(train_data), train_label, stratify=train_label, test_size=0.25,
random_state=27
)
except:
message = client.messages.create(
body='mljar data load and split failed',
from_='+1xxxxxxxxxx', #twilio #
to='+1xxxxxxxxx'
)
print(message.sid)try:
automl = AutoML(mode="Explain")
automl.fit(X_train, y_train)
message = client.messages.create(
body='mljar Explain completed',
from_='+xxxxxxxxxx',
to='+1xxxxxxxx'
)
except:
except:
message = client.messages.create(
body='mljar Explain failed',
from_='+xxxxxxxxx',
to='+1xxxxxxxxxx'Nothing is more disappointing than logging onto your computer after waiting hours for a model to train and finding that it failed hours ago! Prevent this by setting up text or email alerts. It’s simple, fast, and is satisfying when you get the ‘successful completion’ text.

Nothing is more disappointing than logging onto your computer after submitting a script to run and finding that it failed hours ago! Prevent this by setting up text or email alerts. It’s simple, fast, and satisfying when you receive the ‘successful completion’ text.

在提交要运行的脚本并发现其在几个小时前失败之后,没有什么比登录您的计算机更令人失望的了! 通过设置文本或电子邮件警报来防止这种情况。 当您收到“成功完成”文本时,它简单,快速且令人满足。

翻译自: https://towardsdatascience.com/machine-learning-jobs-dont-run-faster-because-you-stare-at-them-ef8b8fe07349

机器学习大作业 新得体会

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值