天天看點

【學習日記】Python | 2020.2.26

主要記錄一些沒懂的還要繼續學的

  1. 第一次接觸類的概念,樓主是EE生,程式設計之前隻學過C和彙編。

    給我的感覺是 類是一種資料類型。像C裡面結構體的格式。

  2. 聽了一個公開課

    講的類似于推薦的

    思路确實不錯

【學習日記】Python | 2020.2.26
【學習日記】Python | 2020.2.26
【學習日記】Python | 2020.2.26
【學習日記】Python | 2020.2.26

源代碼:

import pandas as pd
from matplotlib import pyplot as plt
from sklearn import linear_model
from sklearn.metrics import mean_squared_error
import numpy as np
data = pd.read_csv('data.txt')

#
num = int(data.shape[0]*0.7)
x, y = data[['money']],data[['amount']]

#訓練集測試集
x_train,x_test = x[:num],x[num:]
y_train,y_test = y[:num],y[num:]

#畫圖
plt.scatter(x_train,y_train)

#資料模組化
model = linear_model.LinearRegression()
model.fit(x_train,y_train)

#模型評估
predict_test_y = model.predict(x_test)
print('MSE均方誤差是:%.2f' % mean_squared_error(y_test,predict_test_y))

#預測
new_x = np.array([[84632]])
pre_y = model.predict(new_x)
print(pre_y)

           

data.shape[]

  1. 知識圖譜-推薦算法-圖論-社群發現算法

    語言:(1)工程 java(2)算法 python scala(spark)

  2. 不平衡資料集分類
  3. scikit-learn

繼續閱讀