日韩性视频-久久久蜜桃-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的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 亚洲精品国产免费 | 成人在线观看免费爱爱 | 调教小屁屁白丝丨vk | 中文字幕三级电影 | 成人黄色短视频在线观看 | 玖草在线观看 | 亚洲一一在线 | 精品一区国产 | 激情涩涩| 51精品国产人成在线观看 | 一曲二曲三曲在线观看中文字幕动漫 | 无套内谢少妇露脸 | 91九色国产视频 | 日韩在线观看视频一区二区三区 | 黄色在线小视频 | 亚洲www在线 | 国产精品一区二区不卡 | 91麻豆精品国产 | 久久99精品久久久水蜜桃 | 国产高清视频在线免费观看 | 亚洲伦理在线视频 | 天天舔天天干 | 成人激情久久 | 91av在线免费 | 强制高潮抽搐哭叫求饶h | 伊人网中文字幕 | 亚洲精品视 | 看片网站在线观看 | 岳乳丰满一区二区三区 | x88av在线 | 在线看片网站 | 日本三级吹潮 | 久久久久69 | 欧美日韩中文字幕在线视频 | 日本偷拍一区 | 热热热热色 | 国产乡下妇女做爰毛片 | 婷婷久久伊人 | 久久久久久久中文字幕 | 五月天激情视频 | 真人毛片视频 | 欧美日韩黄色网 | 国产小视频在线 | 亚洲不卡在线视频 | 亚洲色图 校园春色 | 无码人妻久久一区二区三区不卡 | 亚洲精品电影院 | 视频一区二区中文字幕 | 四虎永久在线观看 | 99人妻少妇精品视频一区 | 一级黄色美女 | 国产精品30p | 国产天堂精品 | 欧洲av片 | 国产欧美视频在线观看 | 一区二区三区精彩视频 | 国产精品国产三级国产aⅴ 欧美bbbbbbbbbbbb18av | 99久久精品一区二区成人 | 91亚洲免费 | 人妻在卧室被老板疯狂进入 | 丁香花在线影院观看在线播放 | 亚洲人成亚洲人成在线观看 | 色播av| 欧美自拍在线 | 欧美一级视频免费 | 国产网站免费观看 | 在线观看视频99 | 国产成人久久777777 | 免费在线观看视频a | 香蕉手机网 | 一级视频在线播放 | 色骚网| 欧美午夜视频在线观看 | 性福利视频 | 成人毛片在线观看 | 天堂视频在线观看免费 | 欧美系列第一页 | 激情五月视频 | 天天狠天天操 | 99久久久无码国产精品性波多 | 欧美在线观看免费高清 | 亚洲欧美日韩成人在线 | 国产91免费视频 | 黄视频在线播放 | 欧美高清在线一区 | 欧美一级黄色大片 | 91视频合集 | 用力挺进新婚白嫩少妇 | 久久婷婷综合色丁香五月 | 国产做爰免费视频观看 | 国产在线xx| 中国黄色一级片 | 四虎影院在线免费播放 | 国产一级精品毛片 | 成人在线视频免费看 | 人人操天天射 | 中文字幕 日韩有码 | 天天噜 | 男人天堂a在线 |