库
anaconda&spyder
spyder运行报错ModuleNotFoundError: No module named ‘skleran’
遂使用Anaconda Prompt 命令conda install sklearn
仍然报错,利用PYTHONPATH Manager增加路径(过程中搜索sklearn包地址)
仍然报错,发现把sklearn打错了
vscode
一直用它写Python,但没法debug c++,在反复配置json文件以及path、安装了无数个扩展之后,终于可以断点调试。
pip install scikit-learn 报错
搜索“用pip安装库报错大全”,无果
搜索“pip安装模块报错"in _error_catcher…"的解决办法”:
1开源镜像:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple 库名
失败,该网站不被信任
2 pip --default-timeout=100 install -U 库名,防止下载超时
失败,pip is looking at multiple versions of sklearn to determine which version is compatible,下载了一大堆不同版本的sklearn,等待半小时,无果
最终pip --default-timeout=100 install -U 库名 --use-deprecated=legacy-resolver
成功,vscode可以正常import sklearn
数据集
将mat文件导出为xls文件
队友已导出特征值文件,并将58组周期数据拆分为290组,前13列为特征值,第14列为类别
算法
random forest :
卡在还没划分data和target:AttributeError: ‘DataFrame’ object has no attribute ‘data’
SVM:
vscode跑python代码,终端输出中文乱码
搜到https://blog.csdn.net/qq_47683407/article/details/127726521,修改后无果,暂且按下
报错’utf-8’ codec can’t decode byte 0xcc in position 0: invalid continuation byte
path = 'feature_of_3 after.csv' # 数据文件路径
data = pd.read_csv(path, encoding='gbk',header=None)
报错Found input variables with inconsistent numbers of samples
值错误:发现输入参数变量与样本数不一致。可以输出参数变量的形状查看后修改 0:13改为list(range(13))
调参
poly
train accuracy: 0.5086206896551724
test accuracy: 0.5689655172413793
rbf
train accuracy: 0.646551724137931
test accuracy: 0.6724137931034483
sigmoid
train accuracy: 0.44396551724137934
test accuracy: 0.3793103448275862
C=1 kernel=‘linear’,random_state=28, train_size=0.8
accuracy: 0.896551724137931
accuracy: 0.8793103448275862
C=1 kernel=‘linear’,random_state=28, train_size=0.9
accuracy: 0.8850574712643678
accuracy: 0.896551724137931
C=3 kernel=‘linear’,random_state=28, train_size=0.9
train accuracy: 0.896551724137931
test accuracy: 0.896551724137931
C=4 kernel=‘linear’,random_state=28, train_size=0.9
train accuracy: 0.8879310344827587
test accuracy: 0.9137931034482759
C=5 kernel=‘linear’,random_state=28, train_size=0.9
train accuracy: 0.8879310344827587
test accuracy: 0.896551724137931
C=7 kernel=‘linear’,random_state=28, train_size=0.9
train accuracy: 0.875
test accuracy: 0.896551724137931