在数据集上运行线性回归后,我的RMSE即将达到1109.181

时间:2019-06-06 07:57:52

标签: linear-regression

我正在医学数据集上运行线性回归。

from sklearn.model_selection import train_test_split
train,test=train_test_split(cf_train,random_state=123,test_size=0.2)
x_train=train.drop(["Medicine_ID","Counterfeit_Sales"],1)
y_train=train["Counterfeit_Sales"]
x_test=train.drop(["Medicine_ID","Counterfeit_Sales"],1)
y_test=train["Counterfeit_Sales"]

from sklearn.linear_model import LinearRegression
lm=LinearRegression()
p_test=lm.predict(x_test)
residual=p_test-y_test
rmse=np.sqrt(np.dot(residual,residual)/len(p_test))

完成数据清理部分后,我尝试运行线性回归(正如我所预测的Counterfeit_sales)。但是我的RMSE即将为“ 1109.18”。请告诉我哪里出了问题?

import React, { useState, useEffect } from "react";

function Table({ initialSortDirection, initialSortParam, initialSortEnabled }) {
    const [currentSortData, setSortData] = useState({
        sortDirection: initialSortDirection,
        sortParam: initialSortParam,
        hasSort: initialSortEnabled
    });
    useEffect(() => {
        setSortData({ ...currentSortData, sortDirection: initialSortDirection });
    }, [initialSortDirection]);
    useEffect(() => {
        setSortData({ ...currentSortData, sortParam: initialSortParam });
    }, [initialSortParam]);
    useEffect(() => {
        setSortData({ ...currentSortData, hasSort: initialSortEnabled });
    }, [initialSortEnabled]);
   return (<SomeComponent onChangeSort={setSortData} />)
}

0 个答案:

没有答案