日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Challenge: Machine Learning Basics

發布時間:2025/3/21 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Challenge: Machine Learning Basics 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

1:?How Challenges Work

At Dataquest, we're huge believers in learning through doing and we hope this shows in the learning experience of the missions. While missions focus on introducing concepts, challenges allow you to perform deliberate practice by completing structured problems. You can read more about deliberate practice?here?and?here. Challenges will feel similar to missions but with little instructional material and a larger focus on exercises.

For these challenges, we?strongly?encourage programming on your own computer so you practice using these tools outside the Dataquest environment. You can also use the Dataquest interface to write and quickly run code to see if you’re on the right track. By default, clicking the check code button runs your code and performs answer checking. You can toggle this behavior so that your code is run and the results are returned, without performing any answer checking. Executing your code without performing answer checking is much quicker and allows you to iterate on your work. When you’re done and ready to check your answer, toggle the behavior so that answer checking is enabled.

If you have questions or run into issues, head over to the?Dataquest forums?or our?Slack community.

2:?Data Cleaning

In this challenge, you'll build on the exploration from the last mission, where we tried to answer the question:

  • How do the properties of a car impact it's fuel efficiency?

We focused the last mission on capturing how the weight of a car affects it's fuel efficiency by fitting a linear regression model. In this challenge, you'll explore how the horsepower of a car affects it's fuel efficiency and practice using scikit-learn to fit the linear regression model.

Unlike the?weight?column, the?horsepower?column has some missing values. These values are represented using the???character. Let's filter out these rows so we can fit the model. We've already read?auto-mpg.data?into a Dataframe named?cars.

Instructions

  • Remove all rows where the value for?horsepower?is???and convert the?horsepower?column to a float.
  • Assign the new Dataframe tofiltered_cars.

import pandas as pd
columns = ["mpg", "cylinders", "displacement", "horsepower", "weight", "acceleration", "model year", "origin", "car name"]
cars = pd.read_table("auto-mpg.data", delim_whitespace=True, names=columns)
filtered_cars=cars[cars["horsepower"]!="?"]
filtered_cars["horsepower"]=filtered_cars["horsepower"].astype("float")

3:?Data Exploration

Now that the horsepower values are cleaned, generate a scatter plot that visualizes the relation between the?horsepower?values and thempg?values. Let's compare this to the scatter plot that visualizes?weight?against?mpg.

Instructions

  • Use the Dataframe?plot?to generate 2 scatter plots, in vertical order:
    • On the top plot, generate a scatter plot with thehorsepower?column on the x-axis and the?mpgcolumn on the y-axis.
    • On the bottom plot, generate a scatter plot with the?weight?column on the x-axis and the?mpg?column on the y-xis.

import matplotlib.pyplot as plt
%matplotlib inline
filtered_cars.plot("weight","mpg",kind="scatter")
filtered_cars.plot("acceleration","mpg",kind="scatter")
plt.show()

?

?

4:?Fitting A Model

While it's hard to directly compare the plots since the scales for the x axes are very different, there does seem to be some relation between a car's horsepower and it's fuel efficiency. Let's fit a linear regression model using the horsepower values to get a quantitive understanding of the relationship.

Instructions

  • Create a new instance of the LinearRegression model and assign it to?lr.
  • Use the?fit?method to fit a linear regression model using thehorsepower?column as the input.
  • Use the model to make predictions on the same data the model was trained on (thehorsepower?column fromfiltered_cars) and assign the resulting predictions topredictions.
  • Display the first 5 values inpredictions?and the first 5 values in the?mpg?column fromfiltered_cars.

import sklearn
from sklearn.linear_model import LinearRegression
lr = LinearRegression()
lr.fit(filtered_cars[["horsepower"]], filtered_cars["mpg"])
predictions = lr.predict(filtered_cars[["horsepower"]])
print(predictions[0:5])
print(filtered_cars["mpg"][0:5].values)

Output

[ 19.41604569 13.89148002 16.25915102 16.25915102 17.83759835]

[ 18. 15. 18. 16. 17.]

5:?Plotting The Predictions

In the last mission, we plotted the predicted values and the actual values on the same plot to visually understand the model's effectiveness. Let's repeat that here for the predictions as well.

Instructions

  • Generate 2 scatter plots on the same chart (Matplotlib axes instance):
    • One containing thehorsepower?values on the x-axis against the predicted fuel efficiency values on the y-axis. Use?blue?for the color of the dots.
    • One containing thehorsepower?values on the x-axis against the actual fuel efficiency values on the y-axis. Use?red?for the color of the dots.

import matplotlib.pyplot as plt
%matplotlib inline

plt.scatter(filtered_cars["horsepower"],predictions,c="blue")
plt.scatter(filtered_cars["horsepower"],filtered_cars["mpg"],c="red")
plt.show()

6:?Error Metrics

To evaluate how well the model fits the data, you can compute the MSE and RMSE values for the model. Then, you can compare the MSE and RMSE values with those from the model you fit in the last mission. Recall that the model you fit in the previous mission captured the relationship between the weight of a car (weight?column) and it's fuel efficiency (mpg?column).

Instructions

  • Calculate the MSE of the predicted values and assign tomse.
  • Calculate the RMSE of the predicted values and assign tormse.

?

from sklearn.metrics import mean_squared_error

mse = mean_squared_error(filtered_cars["mpg"], predictions)
print(mse)
rmse = mse ** 0.5
print(rmse)

7:?Next Steps

The MSE for the model from the last mission was?18.78?while the RMSE was?4.33. Here's a table comparing the approximate measures for both models:

?

?WeightHorsepower
MSE18.7823.94
RMSE4.334.89

?

If we could only use one input to our model, we should definitely use the?weight?values to predict the fuel efficiency values because of the lower MSE and RMSE values. There's a lot more before we can build a reliable, working model to predict fuel efficiency however. In later missions, we'll learn how to use multiple features to build a more reliable predictive model.

?

轉載于:https://my.oschina.net/Bettyty/blog/751301

總結

以上是生活随笔為你收集整理的Challenge: Machine Learning Basics的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 看特级毛片 | 日本我不卡 | 在线免费观看不卡av | 精品一区二区三区在线播放 | 国产aaa毛片 | 久久久精品人妻一区二区三区色秀 | 欧美顶级少妇做爰 | 成人动漫在线观看 | 国产50页| 色呦呦视频 | 污网址在线观看 | 爱上av| 国产一区在线免费 | 男人爽女人下面动态图 | 欧美黄色免费 | 在线爱情大片免费观看大全 | 在线观看污网站 | 69堂视频 | 中日韩黄色片 | 欧美色一区二区三区在线观看 | 打开免费观看视频在线 | 国产精品无码专区av在线播放 | 亚洲精品一卡二卡 | 久久综合日本 | 国产无套视频 | 欧美日本韩国在线 | 国产精品91视频 | 中文字幕无产乱码 | 日韩久久久久久久久久 | 日日涩| 日韩无码精品一区二区三区 | 香蕉久久久久久久av网站 | 亚洲色图35p | 精品视频| 欧洲中文字幕日韩精品成人 | 精品视频久久久久久 | 国产高清视频在线免费观看 | 亚洲欧美在线观看视频 | 伊人久久久久噜噜噜亚洲熟女综合 | 97精品国产露脸对白 | 国产综合av | 精品无码一区二区三区的天堂 | 免费在线黄网 | 国产精品5 | 伊人精品一区二区三区 | 国产女人视频 | 成 年 人 黄 色 大 片大 全 | 樱花影院最新免费观看攻略 | 做视频 | 黄色小视频在线观看免费 | 国产偷自拍 | 无遮挡又爽又刺激的视频 | av无码精品一区二区三区 | 日韩一级在线 | 免费网站黄色 | 精品国产aⅴ | 久久爱影视i | 天堂av中文字幕 | 香蕉av777xxx色综合一区 | 五月婷婷视频在线 | 中文字幕a级片 | 不许穿内裤随时挨c调教h苏绵 | 国产香蕉一区 | 高清国产午夜精品久久久久久 | 日韩在线专区 | 69视频一区二区 | 嫩草免费视频 | 欧美成人做爰大片免费看黄石 | 国产香蕉在线视频 | 精品人妻午夜一区二区三区四区 | 在线观看911视频 | 日韩精品999| 干成人网 | 国产aa大片| 亚洲视频图片小说 | 国产视频一二三 | 欧洲一区二区三区四区 | 久久久久久亚洲 | 欧美激情视频网址 | 久久视频一区 | 国产av成人一区二区三区 | 亚洲精品aaa| 亚洲成人欧美 | 爆乳2把你榨干哦ova在线观看 | 丰满人妻一区二区 | 免费福利视频在线观看 | 久久精品国产亚洲av无码娇色 | 影音先锋亚洲一区 | 三级做爰在线观看视频 | 黄色美女大片 | 亚洲精品aaa | 五月婷婷狠狠 | 免费网站在线观看黄色 | 欧美大片91| 成人97| 欧美成人三级在线观看 | 日韩操操| 成人综合婷婷国产精品久久 | 这里只有精品999 |