TypeError: 'CClass' object is not callabl
来源:4-3 生成csv文件
weixin_慕斯1531136
2019-09-22
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import sklearn
import pandas as pd
import os
import sys
import time
import tensorflow as tf
from sklearn.preprocessing import StandardScaler
from tensorflow import keras
print(tf.version) #打印一下版本的问题
print(sys.version_info)
for module in mpl,np,pd,sklearn,tf,keras:
print(module.name,module.version)
from sklearn.datasets import fetch_california_housing
import pprint
from sklearn.model_selection import train_test_split
housing = fetch_california_housing()
print(housing.DESCR)
print(housing.data.shape)
print(housing.target.shape)
pprint.pprint(housing.data[0:5])
pprint.pprint(housing.target[0:5])
x_train_all ,x_test,y_train_all,y_test = train_test_split(
housing.data,
housing.target,
random_state=7
)
x_train,x_valid,y_train,y_valid = train_test_split(
x_train_all,
y_train_all,
random_state=11
)
print(x_train.shape,y_train.shape)
print(x_valid.shape,y_valid.shape)
print(x_test.shape,y_test.shape)
scaler = StandardScaler()
x_train_scaled = scaler.fit_transform(x_train)
x_valid_scaled = scaler.fit_transform(x_valid)
x_test_scaled = scaler.transform(x_test)
output_dir = 'generate_csv’
if not os.path.exists(output_dir):
os.mkdir(output_dir)
def save_to_csv(output_dir, data, name_prefix,
header=None,n_parts = 10):
pass
train_data = np.c_(x_train_scaled,y_train) #这个函数可以按行进行merge操作
valid_data = np.c_(x_valid_scaled,y_valid)
test_data = np.c_(x_train_scaled,y_test)
header_cols = []
print(housing.feature_name)
出现错误
Traceback (most recent call last):
File “C:/study tensorflow/study1/tf.data.csv.py”, line 57, in
train_data = np.c_(x_train_scaled,y_train) #这个函数可以按行进行merge操作
TypeError: ‘CClass’ object is not callable
1回答
-
正十七
2019-09-26
np.c_用中括号
https://stackoverflow.com/questions/34479794/python-np-c-errorcclass-object-is-not-callabel
00
相似问题