total_bedrooms_mean=data['total_bedrooms'].mean() data['total_bedrooms'].fillna(total_bedrooms_mean,inplace=True) onehot=pd.get_dummies((data[['ocean_proximity']]),prefix='ocean_proximity') data.drop(columns = ['ocean_proximity'],inplace=True) X=pd.concat([data['longitude'],data['latitude'],data['housing_median_age'],data['total_rooms'],data['total_bedrooms'],data['population'],data['households'],data['median_income'],onehot],axis=1) y=[data["median_house_value"]] def split_dataset(): # 读取数据集 #dataset = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]] # 从填空中读取测试集比例 test_size = float(entry.get()) # 将数据集分为训练集和测试集 X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=test_size,random_state=42) huafen=(f'X_train: {X_train}, X_test: {X_test}, y_train: {y_train}, y_test: {y_test}') a6=Text(root) a6.place(x=2000, y=100,height=100,width=500) a6.insert(END, huafen)报错With n_samples=1, test_size=0.2 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters.
时间: 2024-01-14 17:02:51 浏览: 28
;
default:
break;
}
printf("排序成功!\n");
}
```
3. 学生信息的输入
```c
// 学生信息的输入
Student *input_student() {
Student *stu = (Student*)malloc(sizeof(Student));
这个错误提示表明在使用 `train_test_split` 函数时,测试集的大小为数据集大小的 20%,但 if (stu == NULL) {
printf("Error: 内存分配失败!\n");
exit(0);
}
是数据集中的样本数量不足以生成训练集和测试集,导致生成的训练集为空。这 printf("请输入学生信息:\n");
printf("学号:");
scanf("%d", &stu->id);
printf可能是由于数据集中的样本数量太少所致。
你可以检查一下数据集中的样本数量("姓名:");
scanf("%s", stu->name);
printf("年龄:");
scanf("%d", &stu->age);
printf("性别:");
scanf(" %c", &stu->gender);
printf("专业:");
scanf("%,看看它们是否足够。如果数据集中的样本数量不足以生成训练集和测试集,你s", stu->major);
stu->next = NULL;
return stu;
}
```
完整的学生信息管理系统如需要考虑使用更小的测试集或者收集更多的数据。
另外,你的代码中也存在一些下:
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// 学生信息结构体
typedef问题。在将目标变量 `y` 定义为 `[data["median_house_value"]]` 时,它的形状 struct student {
int id; // 学号
char name[20]; // 姓名
int age; // 年龄
char gender; // 性别
char major[20]; // 专业
struct student *next; // 单链表的是 `(1, n_samples)`,应该将其转换为 `(n_samples,)` 的形状,即:
```python
y = data["median_house_value"].values
```
这里使用 `.values` 将其转换为 `numpy` 数组,并指针域
} Student;
// 学生信息结点类型
typedef struct student_node {
Student *head; // 单链表且不需要用 `[ ]` 将其包裹。
相关推荐
![csv](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)