【问题标题】:Regression on large dataset: Why does accuracy drop?大型数据集的回归:为什么准确性会下降?
【发布时间】:2018-12-24 07:03:42
【问题描述】:

我正在尝试预测 olx 广告的浏览量。我写了一个刮板来刮掉所有数据(50000)个广告。当我执行线性回归(在 1400 个样本上)时,我得到了 66% 的准确率。但在那之后我对 52000 个样本执行它之后,它下降到了 8%。这是Imgcount vs ViewsPrice vs Views 的统计数据。

我的数据有问题吗?或如何对此进行回归。我知道这个数据非常两极分化。

我想知道使用大型数据集时我的准确率下降的问题是什么。

感谢您的帮助。`

代码:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.neighbors import KNeighborsClassifier
from sklearn.preprocessing import MinMaxScaler
from sklearn import linear_model
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
from sklearn import preprocessing
from sklearn.metrics import accuracy_score
from sklearn.preprocessing import PolynomialFeatures
import seaborn as sns
 url =  '/home/msz/olx/olx/with_images.csv'

df = pd.read_csv(url, index_col='url')


df['price'] = df['price'].str.replace('.', '')
df['price'] = df['price'].str.replace(',', '')
df['price'] = df['price'].str.replace('Rs', '')
df['price'] = df['price'].astype(int)


df['text'] = df['text'].str.replace(',', ' ')
df['text'] = df['text'].str.replace('\t', '')
df['text'] = df['text'].str.replace('\n', '')

X = df[['price', 'img']]
y = df['views'] 

print ("X is like ",  X.shape)
print ("Y is like ",  y.shape)

df.plot(y='views', x='img', style='x')  
plt.title('ImgCount vs Views')  
plt.xlabel('ImgCount')  
plt.ylabel('Views')  
plt.show()

df.plot(y='views', x='price', style='x')  
plt.title('Price vs Views')  
plt.xlabel('Price')  
plt.ylabel('Views')  
plt.show()


from sklearn.model_selection import train_test_split  

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.451, random_state=0)

from sklearn.linear_model import LinearRegression  
regressor = LinearRegression() 
regressor.fit(X_train, y_train) 

score = regressor.score(X_test, y_test)

print('Accuracy is : ',score*100)

【问题讨论】:

  • 欢迎来到 SO。请校对您的问题并更具体。提供代码。
  • 我可以建议你不要编辑我刚刚编辑的所有错别字吗? :0)

标签: matplotlib machine-learning regression linear-regression non-linear-regression


【解决方案1】:

回归是主要适用于线性数据集的基本算法,但如果您有一个大型非线性数据集,则必须使用另一种算法,例如 k-最近邻,或者可能是决策树。但我更喜欢使用朴素贝叶斯分类器等。

【讨论】:

    猜你喜欢
    • 2012-01-18
    • 2020-03-22
    • 2020-06-22
    • 2020-11-19
    • 1970-01-01
    • 2016-08-08
    • 2023-01-10
    • 2020-05-05
    • 1970-01-01
    相关资源
    最近更新 更多